On Thursday, May 22, 2014 12:53:34 PM UTC-7, Derek wrote:
>
> rename db.py to 0.py. it doesn't have to be named db.py.
>
Isn't that the same sort of "kludge" as application.py --->
x_application.py?
But to answer Henrik ... no, there's no workaround other than observing the
naming conventions. I believe this was a design decision, although
well before my time here.
/dps
>
> On Wednesday, May 21, 2014 9:20:16 AM UTC-7, Henrik Holm wrote:
>>
>> 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.