Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

table format is not used if it is defined later than the reference #610

Closed
niphlod opened this issue Jan 26, 2015 · 1 comment
Closed

table format is not used if it is defined later than the reference #610

niphlod opened this issue Jan 26, 2015 · 1 comment

Comments

@niphlod
Copy link
Member

niphlod commented Jan 26, 2015

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:

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.

Original issue: http://code.google.com/p/web2py/issues/detail?id=700

@niphlod
Copy link
Member Author

niphlod commented Jan 26, 2015

From ABasta...@gmail.com on August 07, 2012 19:52:32

Labels: -Type-Defect Type-Enhancement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants