I have a model file 'application.py' wherein I define some tables, and it 
is executed before the db.py file.  Thus I get the "name 'db' is not 
defined" error.

For now I have renamed the file to x_application.py, but this seems like 
kind of a kludge. Is there a way to work around the "alphabetical order" 
restriction?  

(Sorry to respond to an old message; I didn't find any newer references to 
this particular problem.)


Henrik



On Monday, September 24, 2012 1:51:21 PM UTC-4, Massimo Di Pierro wrote:
>
> db should be defined in your models/db.py
>
> db= DAL(....)
>
> Models are executed in alphabetical order. It will not be there for you if 
> you deleted db.py or name your model so that it is executed before db.py.
>
> Massimo
>
> On Monday, 24 September 2012 05:26:26 UTC-5, Роман Акимов wrote:
>>
>> Hello all!
>> Please help me.
>> I'm write:
>>
>> model
>> db.define_table(
>>     'document_body',
>>     Field('name'),
>>     Field('number'),
>>     Field('created', 'datetime', default=request.now),
>>     Field('start_date', 'date'),
>>     Field('end_date', 'date'),
>>     Field('activity', 'boolean', default=True),
>>     )
>>
>> controller
>> def index():
>>     form = SQLFORM(db.document_body)
>>     if form.process().accepted:
>>         response.flash = 'document uploaded'
>>     return dict(form = form)
>>
>> And i have error in default.py:
>> <type 'exceptions.NameError'> global name 'db' is not defined
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to