On Monday, March 16, 2015 at 6:41:57 AM UTC-7, Val K wrote:
>
> Hi!
> As I see, you defined your table in the db.py, but 'db=DAL(...) ' is 
> already exist in this file, I mean auth-settings and etc.
> If you want to use another database for your tables, I suppose, you must 
> use another storage (not storage.sqlite) and another name for it ('my_db' 
> instead 'db'  for example)
>
>
There shouldn't be any problem with having multiple tables using the same 
"db=DAL(...)" statement.

In the app I'm working on here on this machine, I have db.py pretty much as 
shipped by Massimo and the crew (I add another validator to it as the only 
change).
My application-specific tables are defined in separate model files:  
localdb.py, for instance, just contains 1 line (aside from a lot of 
comments out db.py)

db.define_table('localtable',Field 
<http://10.3.171.86:8000/examples/global/vars/Field>('localtime', 'datetime'), 
Field <http://10.3.171.86:8000/examples/global/vars/Field>('localwho', 
'string'), Field 
<http://10.3.171.86:8000/examples/global/vars/Field>('localstatus', 'string'))


Note that model files are read in alphabetical order, so for me db.py gets 
run first then localdb.py.  And the DAL() call is only run from the db.py.

For a small app, putting the define_table into db.py should be okay, just 
put it at the bottom of the file.  My app gets new (additional) tables 
every once and a while, as I find a new use for the server, and its 
convenient to put those new tables in their own file.  The only gotcha I'm 
aware of is the order-of-run, so I don't have a "bob.py", I have a 
"localbob.py".

/dps



-- 
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