On Thursday, 6 March 2014 13:09:18 UTC+11, Anthony wrote:
>
> But I believe you should be able to define tables out of order (i.e., 
> define the referenced table after the referencing table).
>

Only when lazy_tables = True


 

>
> On Wednesday, March 5, 2014 7:55:13 PM UTC-5, Tim Richardson wrote:
>>
>> Model files in the same directory execute alphabetically; it seems that 
>> you are seeing correct behaviour. 
>> This behaviour predates v2.8.2 by quite some time as far as I know. 
>>
>> the book says 
>> Models in the same folder/subfolder are executed in alphabetical order.
>>
>>
>> https://do.growthpath.com.au/book/default/chapter/29/04/the-core?search=alphabetical#Workflow
>>
>> I think this means you can assume nothing will change. I think you should 
>> change your file names.
>>
>> You can dynamically change load order as documented in the book, but it's 
>> tricky to use in my experience. 
>>
>> On Wednesday, 5 March 2014 04:46:44 UTC+11, Donatas Burba wrote:
>>>
>>>
>>> After upgrading to v2.9.3 (from 2.8.2), error is thrown:
>>>
>>> Traceback (most recent call last):
>>>   File "/vagrant/grand/web2py/gluon/restricted.py", line 217, in restricted
>>>     exec ccode in environment
>>>   File "/vagrant/grand/web2py/applications/grand/models/db_contract.py", 
>>> line 13, in <module>
>>>     Field('actual_date', 'date', readable=False, writable=False)
>>>   File "/vagrant/grand/web2py/gluon/dal.py", line 8223, in define_table
>>>     table = self.lazy_define_table(tablename,*fields,**args)
>>>   File "/vagrant/grand/web2py/gluon/dal.py", line 8260, in lazy_define_table
>>>     polymodel=polymodel)
>>>   File "/vagrant/grand/web2py/gluon/dal.py", line 925, in create_table
>>>     raise KeyError('Cannot resolve reference %s in %s definition' % 
>>> (referenced, table._tablename))
>>> KeyError: 'Cannot resolve reference subject_subject in contract_contract 
>>> definition'
>>>
>>> With lazy_tables=True everything is ok, but in development environment I 
>>> don't want use True value. My table definitions are grouped in separate 
>>> files, so situation is next:
>>>
>>> models/db_contract.py:
>>>
>>> db.define_table('contract_contract'
>>>
>>>     ...
>>>
>>>     Field('subject_id', 'reference subject_subject')
>>>
>>>     ...
>>>
>>> )
>>>
>>>
>>> models/db_subject.py
>>>
>>> db.define_table('subject_subject',
>>>
>>>     ...
>>>
>>> )
>>>
>>> As I understand the problem occurs because db_contract.py is executed 
>>> before db_subject.py, Is it posible to revert back to executement like in 
>>> v2.8.2 (it means that such situation won't throw any error without setting 
>>> lazy_tables to True)? Or it is new feature?
>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to