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

niphlod opened this issue Jan 26, 2015 · 1 comment

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

niphlod opened this issue Jan 26, 2015 · 1 comment


Copy link

@niphlod niphlod commented Jan 26, 2015

From 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:


This comment has been minimized.

Copy link
Member Author

@niphlod niphlod commented Jan 26, 2015

From on August 07, 2012 19:52:32

Labels: -Type-Defect Type-Enhancement

@niphlod niphlod added the DAL label Mar 8, 2015
@gi0baro gi0baro removed the 2–5 stars label Mar 20, 2015
@niphlod niphlod closed this Sep 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.