nameerror

How to create a rails habtm that deletes/destroys without error?

I created a simple example as a sanity check and still can not seem to destroy an item on either side of a has_and_belongs_to_many relationship in rails. Whenever I try to delete an object from either table, I get the dreaded NameError / "uninitialized constant" error message. To demonstrate, I created a sample rails app with a Boy c...

Getting the name which is not defined from NameError in python.

Hello! As you know, if we simply do: >>> a > 0 Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> a > 0 NameError: name 'a' is not defined Is there a way of catching the exception/error and extracting from it the value 'a'. I need this because I'm evaluating some dynamically created expressions, and woul...

Why doesn't import prevent NameError in a python script run with execfile()?

I looked at a number of existing questions about NameError exceptions when scripts are run with exec statements or execfile() in Python, but haven't found a good explanation yet of the following behavior. I want to make a simple game that creates script objects at runtime with execfile(). Below are 4 modules that demonstrate the proble...

function not defined but really is defined...

I am writing a script and in my script I have this function: def insert_image(cursor, object_id, sku): product_obj = core.Object.get(object_id) string_sku = str(sku) folder = string_sku[0] + string_sku[1] + string_sku[2] found_url = False # KLUDGE This is ugly and redundant, however putting this in an if elif elif el...

Rails3 and Sass::Plugin::options

When I try to add "Sass::Plugin.options[:style] = :compact" to environment.rb I get "uninitialized constant Sass (NameError)" when I try to start up my server. I have added "gem 'haml', '3.0.0'" to my Gemfile. Anybody ran into this? ...

[Python] name 'OptionGroup' is not defined

This error is done strictly by following examples found on the docs. And you can't find any clarification about it anywhere, be it that long long docs page, google or stackoverflow. Plus, reading optparse.py shows OptionGroup is there, so that adds to the confusion. Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) >>> from optparse imp...

Django Error: NameError name 'current_datetime' is not defined

I'm working through the book "The Definitive Guide to Django" and am stuck on a piece of code. This is the code in my settings.py: ROOT_URLCONF = 'mysite.urls' I have the following code in my urls.py from django.conf.urls.defaults import * from mysite.views import hello, my_homepage_view urlpatterns = patterns('', ('^hello/$', hell...

Python: NameError: 'self' is not defined

I must be doing something stupid. I'm running this in Google App Engine: class MainHandler(webapp.RequestHandler): def render(self, template_name, template_data): path = os.path.join(os.path.dirname(__file__), 'static/templates/%s.html' % template_name) self.response.out.write(template.render(path, template_data)) #...

Python and Plone help

Im using the plone cms and am having trouble with a python script. I get a name error "the global name 'open' is not defined". When i put the code in a seperate python script it works fine and the information is being passed to the python script becuase i can print the query. Code is below: #Import a standard function, and get the H...

calling class from an external module causes NameError, in IDLE it works fine

i have the following code in a module called code_database.py class Entry(): def enter_data(self): self.title = input('enter a title: ') print('enter the code, press ctrl-d to end: ') self.code = sys.stdin.readlines() self.tags = input('enter tags: ') def save_data(self): with open('entry...

ruby: irb gives NameError attempting to use mechanize gem (ubuntu)

On my ubuntu box, irb (ruby) gives a NameError when I try to use the mechanize gem: $ irb irb(main):001:0> require 'mechanize' => true irb(main):002:0> Mechanize.new NameError: uninitialized constant Mechanize from (irb):2 from :0 gem env shows this: RubyGems Environment: - RUBYGEMS VERSION: 1.3.7 - RUBY VERSION: 1.8.7 (2...

Rails 3 - Getting NameError after accessing models via has_many

Hey folks, I have following models: class App::Module::Object < AR::Base has_many :objects, :class_name => 'App::OtherModule::Object' end and class App::OtherModule::Object < AR::Base belongs_to :object, :class_name => 'App::Module::Object' end Using Rails 3.0.0 and Ruby 1.9.2, I get following error after accessing App::Module...

Python import module results in NameError

I'm having a module import issue. using python 2.6 on ubuntu 10.10 I have a class that subclasses the daemon at http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/ . I created a python package with a module containing code that imports some models from a django project. The code works when used from a class, no...