Anthony,

You pointed me in the right direction. I thought DAL() was
systematically importing the model... my wrong.
Once I added auto_import=True everything worked as expected.
Thanks a lot.


PS: Many thanks too to the others who gave me some advice ;-)

On Feb 7, 6:26 pm, Anthony <abasta...@gmail.com> wrote:
> > Just tried it -> same results.
> > FYI, I'm only using the interactive python shell to illustrate the
> > problem I face I my app...
>
> When you use the -M option to load your models, are you then still doing
> this in your shell session:
>
> >>> db = DAL('postgres://postgres:********@localhost/courier')
>
> If so, don't -- the db object will already be defined when your db.py file
> is executed, and the above will end up overwriting it (and therefore losing
> all of its table definitions from db.py). Just do:
>
> python web2py.py -S courier -M -N
>
> >>> db.tables
>
> (Note the -N option -- that prevents cron from starting.)
>
> If you're using the DAL outside of a web2py app, then you'll still need to
> create model definitions (i.e., with db.define_table) in your code -- the
> DAL doesn't know what tables and fields are in your db unless you tell it
> by defining the models. However, if you have already defined the models in
> an app somewhere, you might be able to make use of
> auto_import:http://web2py.com/books/default/chapter/29/6#Using-DAL-without-define....
>
> Anthony

Reply via email to