You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem? 1. t1 = db.define_table('t1', Field('a', 'reference t2'))
2. t2 = db.define_table('t2', Field('a', 'string'), format='t2:%(a)s') What is the expected output? What do you see instead? I expect t1.a.represent to use the t2 format, but it doesn't. If I reverse the order of the definitions, it works as expected.
If the tables have circular or mutual references, there is no order in which everything will work. What version of the product are you using? On what operating system? all Please provide any additional information below. The problem is that sqlhtml_validators() is applied at t1 definition time, when t2 does not exist yet (and therefore the format cannot be made to represent). My temporary solution: after all tables are defined, I fix representations with the following function:
from gluon.dal import sqlhtml_validators
def dalfix(tables, fields):
for t in tables:
for f in fields:
t[f].requires = sqlhtml_validators(t[f])
And in this case, the fixing call would be:
dalfix([db.t1], ['a'])
(I use lists because in the real app I have multiple tables and multiple repeating fields to fix)
Note this this is related to issue #648 , which was marked as a duplicate (of #649) but is not a duplicate and is still unsolved (but I cannot find a way to reopen). The discussion there offers a possible way to a solution.
From i.like.p...@gmail.com on March 09, 2012 05:31:33
What steps will reproduce the problem? 1. t1 = db.define_table('t1', Field('a', 'reference t2'))
2. t2 = db.define_table('t2', Field('a', 'string'), format='t2:%(a)s') What is the expected output? What do you see instead? I expect t1.a.represent to use the t2 format, but it doesn't. If I reverse the order of the definitions, it works as expected.
If the tables have circular or mutual references, there is no order in which everything will work. What version of the product are you using? On what operating system? all Please provide any additional information below. The problem is that sqlhtml_validators() is applied at t1 definition time, when t2 does not exist yet (and therefore the format cannot be made to represent). My temporary solution: after all tables are defined, I fix representations with the following function:
And in this case, the fixing call would be:
(I use lists because in the real app I have multiple tables and multiple repeating fields to fix)
Note this this is related to issue
#648
, which was marked as a duplicate (of#649
) but is not a duplicate and is still unsolved (but I cannot find a way to reopen). The discussion there offers a possible way to a solution.Original issue: http://code.google.com/p/web2py/issues/detail?id=700
The text was updated successfully, but these errors were encountered: