hello
when use in controller default.py
def sql_form():
sqlform=SQLFORM.grid(db.mydb, fields=['name','info'])
return dict(sqlform=sqlform)
generate ERROR ticket
<type 'exceptions.AttributeError'> 'str' object has no attribute
'_tablename'
web2py™ (2, 0, 6, datetime.datetime(2012, 9, 2, 4, 44, 23), 'stable')
Python Python 2.6.6: /usr/bin/python Traceback
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
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/s_users/controllers/default.py"
<https://10.100.100.104/admin/default/edit/sip_users/controllers/default.py>,
line 119, in <module>
File "/home/www-data/web2py/gluon/globals.py", line 185, in <lambda>
self._caller = lambda f: f()
File "/home/www-data/web2py/applications/s_users/controllers/default.py"
<https://10.100.100.104/admin/default/edit/sip_users/controllers/default.py>,
line 64, in sql_form
sqlform=SQLFORM.grid(db.sip_conf_db, fields=['name','info'])
File "/home/www-data/web2py/gluon/sqlhtml.py", line 1701, in grid
if field._tablename in tablenames]
AttributeError: 'str' object has no attribute '_tablename'
Error snapshot
<type 'exceptions.AttributeError'>('str' object has no attribute
'_tablename')
Code listing
1696.
1697.
1698.
1699.
1700.
1701.
1702.
1703.
1704.
1705.
fields = reduce(lambda a,b:a+b,
[[field for field in table] for table in tables])
if not field_id:
field_id = tables[0]._id
columns = [str(field) for field in fields \
if field._tablename in tablenames]
if not str(field_id) in [str(f) for f in fields]:
fields.append(field_id)
table = field_id.table
__________________
but when used
SQLFORM (db.mydb, fields=['name','info'])
all working normal.
thanks
--