Ok, now I understand... That should work.

About the suggestion, I have no single key for table and field tuple... The
database table is not normalized and the only way I found so far is to use
a composed pk formed with table and field to refer to unique field entry.
If I had not identical field name in differents tables I could avoid that.

Anyway, until now it has work well, I may need to better engineer this part
of my database in the future thought.

Thanks

Richard

On Thu, Oct 18, 2012 at 6:31 PM, Niphlod <niph...@gmail.com> wrote:

> 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> 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(**dblabel**s_en[db.table._**tablename+db.**
>>>> table.field.name <http://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
>>>>
>>>  --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 



Reply via email to