you are calling db.table1 somewhere. In my code there is no db.table1 at all....just tried, works. Readable example
tablename = 'test1' labels = dict(test1_foo='test1label') db.define_table(tablename, Field('foo', label=labels["%s_foo" % tablename]) ) BTW: you'd be better off separating table name and field name in your labels dict (or even, structure it as dict(table=tablename,fields=dict(fieldname=label))). If you have a table named *foo* with a field *bar* and a table *foob* with a column *ar* you are going to display the same label for both ;-) On Thursday, October 18, 2012 11:09:56 PM UTC+2, Richard wrote: > > I still get <type 'exceptions.AttributeError'> 'DAL' object has no > attribute 'table1' > > You right that I didn't need call db.table._tablename and > db.table.field.name... I was just trying something else before then I > forget I didn't need to call those attributes. > > Anyway, I think it is not possible since model is not yet define. > > FYI dblables_en is a dict like this one {'table1field1': > 'field1LableStoreInDb'} > > Thanks. > > Richard > > On Thu, Oct 18, 2012 at 4:40 PM, Niphlod <nip...@gmail.com > <javascript:>>wrote: > >> you are asking to python to evaluate a variable that doesn't exists. >> It seems that you know the tablename and fields in advance (because >> dblabels_en is somewhat filled already) so why can't you just >> >> tablename = 'test1' >> db.define_table(tablename, >> Field('foo', label=T(dblabels_en["%s_foo" % tablename]))) >> >> ? >> >> >> On Thursday, October 18, 2012 9:57:09 PM UTC+2, Richard wrote: >>> >>> Hello, >>> >>> Is it possible to do that? >>> db.define_table(... >>> Field(... >>> label=T(dblabels_en[db.table._**tablename+db.table.field.name]**) >>> >>> I can do >>> db.define_table(...) >>> db.table.field.lable=T(**dblabels_en[db.table._**tablename+ >>> db.table.field.name]**) >>> >>> Inside table model definition "table" is not yet define then I can refer >>> to it. >>> >>> I try with lambda with no succes. >>> >>> Do you see a way to refer to the db.table._tablename in order to make it >>> execute only once that the model is defined? >>> >>> Thanks >>> >>> Richard >>> >> -- >> >> >> >> > > --