[web2py] Re: How to reuse the db definition?

2012-04-07 Thread Massimo Di Pierro
Do not se exec_environment. create a module (not a model) and in it put something like: from gluon import * def define_common_tables(db): request, response, session, cache, T = current.request, current.response, current.session, current.cache, current.T db.define_table('table1',)

[web2py] Re: How to reuse the db definition?

2012-04-07 Thread Anthony
Another option might be http://web2py.com/books/default/chapter/29/6#Using-DAL-without-define-tables. Note, in that case, the table definitions will include the field names and types, but not the non-database related web2py-specific attributes, such as validators, labels, widgets, default valu

[web2py] Re: How to reuse the db definition?

2012-04-07 Thread Massimo Di Pierro
I would like to stress once more a design issue. If two apps share the same table/model there are two cases: a) the apps are independent (it is possible to distribute them independently) b) the apps are dependent (they must be distributed together) In case a) the model cannot be shared. Each ap

Re: [web2py] Re: How to reuse the db definition?

2012-04-07 Thread Ronghui Yu
Actually I have only one app. What I am going to do is to import the initial data into database from some text format files. I need to write a Python script to read from the source file, and do some operations on the data, then insert into database. I could do that via pure SQL, but I like the way