You can define tables in module but you need something like #in module def define_tables(db,request,T,auth): db.define_table('sometable,Field('blablabla',default=auth.user_id,requires=IS_NOT_EMPTY(error_message=T("cannot be emtpy"))))
#in controller module=local_import('module') module.define_tables(db,request,T,auth) On May 7, 4:15 am, annet <annet.verm...@gmail.com> wrote: > I read this post in the > group:http://groups.google.com/group/web2py/browse_thread/thread/6201f9f56b..., > and I am facing a similar problem. > > I have one web2py installation in which I have a base application > which contains all shared files i.e .js and .css files. Within this > application I also defined all database tables, so all .table files > are in the databases folder of this application. Furthermore this > web2py installation contains an init application and b2c, b2b, crm > applications. The db.py files of these applications are copies of the > db.py of the base application with all migrates set to False. From the > post mentioned above I understand I can make a function of the base > app's db.py, name it db_stuff.py and put it in the base application's > modules file: > > /web2py/applications/base/modules/db_stuff.py > > My first question is: how do I make a function of a db.py file, and > which parts of the db.py file should the function contain? > > Then, I should write an import statement in each of the applications > db.py files: > > local_import('db_stuff',app='base') > > My second question is: what code do these db.py files contain apart > from the import statement? > > Kind regards, > > Annet.