On Dec 19, 9:42 am, SergeyPo <ser...@zarealye.com> wrote:
> I name all my files with
> starting underscore, this ensures that the files are loaded before
> db.py In each 'underscored' file I create definitions for different
> tables or sets of tables. Than in db.py I just collect everything.
> E.g.:
> _definitions.py  file contains:
> table1_fields = (SQLField('name1', 'string'),
>                         SQLField('name2', 'string'),
>                        SQLField('name3', 'string'))
> db.py file contains:
> db.define_table('headers',
>     *table1_fields
> )

Thanks for sharing your idea...I'm not sure this buys me very much
though.
I have a whole bunch of stuff for each table:
db.table.represent
db.table.field.requires
db.table.field.label
db.table.field.comment

All of this should also be in the separate file.

I tried making the main file load 1st by renaming as _db.py &
therefore hoping this would make it's tables visible to the other
files, but no joy.

Looking through gluon, I see that run_models_in(environment) executes
each model independently (based on the modified listdir as you
helpfully point out).

Could I modify the idea suggested further to have all the stuff
associated with a table defined in the separate file in a big dict &
then simply exec that in db.py?

Something to experiment with whilst seeing if there's a nicer way
(this doesn't half seem ugly!)

F
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to