There are some things you can do to alleviate the situation.

First, you can name you models so that they execute in the correct order.

A_db.py
B_user.py
C_post.py
E_tag.py

That said, I usually try to keep all related models in the same file.
In your case you might have

B_user.py
C_weblog.py

Since post and tag both belong to the same logical set of tables,
stick them together in one file. For objects, I also might subset it
simpler such as

C_weblog.py
C_weblog_objects.py # contains virtualfield definitions.

--
Thadeus





On Wed, Jun 9, 2010 at 4:42 PM, mdipierro <mdipie...@cs.depaul.edu> wrote:
> No. This the main issue with web2py design. This is the price we pay
> for not having imports of models.
>
> On Jun 9, 4:21 pm, Binh <btbinht...@gmail.com> wrote:
>> Hi,
>>
>> I am trying to create an orm setup like in ruby on rails with the DAL.
>> I have a user, post, and tag model.
>> A user has many posts.
>> A tag belongs to a user.
>> A post has and belongs to many tags.
>> A tag has and belongs to many posts.
>>
>> I have 4 separate files in my models folder: db.py, user.py, post.py,
>> and tag.py
>> db.py contains the db connection and mail configurations.
>> The respective model files define the table structure and have a class
>> named after the model to implement virtual fields.
>>
>> I noticed that defining the tables with relationships in the separate
>> files does not work properly.
>> The model files would load which appears to be in alphabetical order.
>> So, my db.py would load first and then post.py which fails.
>> post.py fails to recognize the table definition in user.py, so it
>> cannot define the belongs to relationship.
>>
>> Is their anyway to setup a model file to import all the other models
>> without the hassle of file load order and possibly import order which
>> rails does implicitly?
>

Reply via email to