[web2py] Re: global name 'db' is not defined

2014-05-28 Thread Anthony
> > Would it make sense to have the first model file be named something like > 0_db.py - so that it is always run first? > Sure. You can name your model files whatever you want. > By the way: Am I doing the right thing here, by not modifying the db.py > file and instead adding my own file t

Re: [web2py] Re: global name 'db' is not defined

2014-05-27 Thread Jonathan Lundell
On 27 May 2014, at 6:21 AM, Henrik Holm wrote: > On Tuesday, May 27, 2014 8:46:19 AM UTC-4, Anthony wrote: > > I suppose we could add a setting that allows you to specify model order, > though for backward compatibility, the initial model file (i.e., the one > where you make that setting) woul

[web2py] Re: global name 'db' is not defined

2014-05-27 Thread Henrik Holm
On Tuesday, May 27, 2014 8:46:19 AM UTC-4, Anthony wrote: > I suppose we could add a setting that allows you to specify model order, > though for backward compatibility, the initial model file (i.e., the one > where you make that setting) would have to be first alphabetically. > Would it make

[web2py] Re: global name 'db' is not defined

2014-05-27 Thread Anthony
Also, note that you can move your model definitions to modules and then import and run them in any order you want. Anthony On Tuesday, May 27, 2014 8:46:19 AM UTC-4, Anthony wrote: > > On Tuesday, May 27, 2014 8:09:43 AM UTC-4, Henrik Holm wrote: >> >> Anthony, >> >> Not sure really - I was wond

[web2py] Re: global name 'db' is not defined

2014-05-27 Thread Anthony
On Tuesday, May 27, 2014 8:09:43 AM UTC-4, Henrik Holm wrote: > > Anthony, > > Not sure really - I was wondering if there might be a way to specify the > order of which the files would be executed. > I suppose we could add a setting that allows you to specify model order, though for backward com

[web2py] Re: global name 'db' is not defined

2014-05-27 Thread Henrik Holm
On Thursday, May 22, 2014 8:41:16 PM UTC-4, Dave S wrote: > 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? > Somehow this feels less "k

[web2py] Re: global name 'db' is not defined

2014-05-27 Thread Henrik Holm
Anthony, Not sure really - I was wondering if there might be a way to specify the order of which the files would be executed. Henrik On Thursday, May 22, 2014 8:50:39 PM UTC-4, Anthony wrote: > > For now I have renamed the file to x_application.py, but this seems like >> kind of a kludge. Is

[web2py] Re: global name 'db' is not defined

2014-05-22 Thread Anthony
> > 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? > What kind of workaround do you envision? Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentatio

[web2py] Re: global name 'db' is not defined

2014-05-22 Thread Dave S
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 convention

[web2py] Re: global name 'db' is not defined

2014-05-22 Thread Derek
rename db.py to 0.py. it doesn't have to be named db.py. 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

[web2py] Re: global name 'db' is not defined

2014-05-22 Thread Henrik Holm
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 "alphabetic

[web2py] Re: global name 'db' is not defined

2013-01-26 Thread fa0425
Hi I ran into this problem while following Massimo's book (btw, thanks for your efforts - it's good to have a chance to do this directly). In 3.7 (Adding Crud), it wasn't obvious at first that the addition of crud should come AFTER the database ('db' in this case) is defined. I moved the two c

[web2py] Re: global name 'db' is not defined

2012-09-26 Thread Massimo Di Pierro
Crud.update should be crud.update crud an object which belongs to class Crud. On Wednesday, 26 September 2012 12:16:25 UTC-5, Роман Акимов wrote: > > > > понедельник, 24 сентября 2012 г., 23:51:21 UTC+6 пользователь Massimo Di > Pierro написал: >> >> db should be defined in your models/db.py >

[web2py] Re: global name 'db' is not defined

2012-09-26 Thread Роман Акимов
понедельник, 24 сентября 2012 г., 23:51:21 UTC+6 пользователь Massimo Di Pierro написал: > > 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 b

[web2py] Re: global name 'db' is not defined

2012-09-24 Thread samuel bonilla
db = DAL('sqlite://storage.sqlite') # db = sqlite, pymongo, mysql, postgresql etc... db.define_table( 'document_body', Field('name', requires=IS_NOTEMPTY()), Field('number'), Field('created', 'datetime', default=request.now), Field('start_date', 'date'), Field('end_date', 'dat

[web2py] Re: global name 'db' is not defined

2012-09-24 Thread Massimo Di Pierro
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! >