Or better this should be:
table = sqlrows.db[t]
if f in table.fields:
headers[c] = table[f].label
else:
On Monday, 8 October 2012 11:55:23 UTC-5, Massimo Di Pierro wrote:
>
> The error is that in plugin_powertable.py there are these lines:
>
> try:
> headers[c] = sqlrows.db[t][f].label
> except KeyError:
>
> They should be changed to
>
> try:
> headers[c] = sqlrows.db[t][f].label
> except (KeyError, AttributeError):
>
> The fact is that table[f] when f is an invalid key now raises an
> AttributeError, not a KeyError. That is because table[f] is the same as
> getattr(table,f). While we can change and revert this behavior, making
> table['f'] equivalent to table.f instead of vice versa resulted in a 10x
> improvement while extracting data from DAL.
>
>
>
> On Monday, 8 October 2012 10:44:15 UTC-5, Don_X wrote:
>>
>> it runs by bypassing the admin/default/index page ...
>> but F.Y.I
>>
>> the powertable app example still does not run : I get the following error
>> :
>>
>>
>> <type 'exceptions.AttributeError'> 'Row' object has no attribute
>> 'product'
>> Versionweb2py™(2, 1, 0, datetime.datetime(2012, 10, 8, 15, 17, 50),
>> 'dev')PythonPython 2.7.3: /usr/bin/python
>>
>>
>> Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>>
>> Traceback (most recent call last):
>> File "/home/www-data/web2py/gluon/restricted.py", line 209, in restricted
>> exec ccode in environment
>> File
>> "/home/www-data/web2py/applications/powertable/controllers/default.py"
>> <http://web2py.loc/admin/default/edit/powertable/controllers/default.py>,
>> line 80, in <module>
>> File "/home/www-data/web2py/gluon/globals.py", line 187, in <lambda>
>> self._caller = lambda f: f()
>> File
>> "/home/www-data/web2py/applications/powertable/controllers/default.py"
>> <http://web2py.loc/admin/default/edit/powertable/controllers/default.py>,
>> line 25, in index
>> table = table.create()
>> File
>> "/home/www-data/web2py/applications/powertable/models/plugin_powertable.py"
>> <http://web2py.loc/admin/default/edit/powertable/models/plugin_powertable.py>,
>> line 810, in plugin_powertable
>> PowerTable(),
>> File
>> "/home/www-data/web2py/applications/powertable/models/plugin_powertable.py"
>> <http://web2py.loc/admin/default/edit/powertable/models/plugin_powertable.py>,
>> line 214, in __init__
>> _id = record[keycolumntbl][keycolumnfld]
>> File "/home/www-data/web2py/gluon/dal.py", line 6376, in __getitem__
>> return ogetattr(self, key)
>> AttributeError: 'Row' object has no attribute 'product'
>>
>>
>> I wish I knew how to fix this ! ... I will try though !
>>
>>
--