Invalid field name although rname is set

335 views
Skip to first unread message

Edwin Haver

unread,
Nov 11, 2016, 1:40:32 AM11/11/16
to web2py-users

Hello,

Why do I get the following error message when I have set the rname for that field and have set check_reserved to None?

<type 'exceptions.SyntaxError'> Field: invalid field name: update, use rname for "funny" names

Version

web2py™Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
PythonPython 2.7.12: C:\Python27\python.exe (prefix: C:\Python27)

Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
Traceback (most recent call last):
File "C:\Users\Edwin\Applications\web2py\gluon\restricted.py", line 227, in restricted
exec ccode in environment
File "C:/Users/Edwin/Applications/web2py/applications/create/models/db_tables.py", line 24, in <module>
Field('update', rname='wac_update', type='string', default=None),
File "C:\Users\Edwin\Applications\web2py\gluon\packages\dal\pydal\objects.py", line 1438, in __init__
'use rname for "funny" names' % fieldname)
SyntaxError: Field: invalid field name: update, use rname for "funny" names


Regards, Edwin

Niphlod

unread,
Nov 11, 2016, 6:17:36 AM11/11/16
to web2py-users
update() is a method............you can't use a model that has a field that is named "update". It's true that you're using rname, but the problem is that you need to choose a less "funny" name for the field name, not the rname.

Anthony

unread,
Nov 11, 2016, 8:30:09 AM11/11/16
to web...@googlegroups.com
Field names cannot be Python keywords or attribute names of the Table object, even if using rname. The Table class inherits from pydal.helpers.classes.BasicStorage, which has methods "update", "get", "keys", "values", etc. -- so none of those will work as field names (though you can use them as rnames).

Anthony

Edwin Haver

unread,
Nov 11, 2016, 10:23:13 PM11/11/16
to web2py-users
Thank you for the explanation. The error message is a bit misleading in this respect.
Reply all
Reply to author
Forward
0 new messages