I have a Field('orgs', 'list: reference org') and I got the message
AttributeError: 'int' object has no attribute 'id'
This is the traceback:
Version web2py™ Version 2.12.3-stable+timestamp.2015.08.19.00.18.03
Traceback
Traceback (most recent call last):
File "c:\web2py\gluon\restricted.py", line 227, in restricted
exec ccode in environment
File "c:/web2py/applications/secure/controllers/personenaendern.py", line
499, in <module>
File "c:\web2py\gluon\globals.py", line 412, in <lambda>
self._caller = lambda f: f()
File "c:\web2py\gluon\tools.py", line 3774, in f
return action(*a, **b)
File "c:/web2py/applications/secure/controllers/personenaendern.py", line
402, in person1
form=SQLFORM(db.auth_user, person_id, submit_button=submit_msg,
showid=showid)
File "c:\web2py\gluon\sqlhtml.py", line 1226, in __init__
inp = represent(field, default, record)
File "c:\web2py\gluon\sqlhtml.py", line 68, in represent
return f(value)
File "c:\web2py\gluon\packages\dal\pydal\helpers\methods.py", line 283,
in __call__
_fieldformat(self.ref, x.id) for x in value) or ''
File "c:\web2py\gluon\packages\dal\pydal\helpers\methods.py", line 283,
in <genexpr>
_fieldformat(self.ref, x.id) for x in value) or ''
AttributeError: 'int' object has no attribute 'id'
The error comes from
class _repr_ref_list(_repr_ref):
def __call__(self, value, row=None):
if not value:
return None
refs = None
db, id = self.ref._db, self.ref._id
if db._adapter.dbengine == 'google:datastore':
def count(values):
return db(id.belongs(values)).select(id)
rx = range(0, len(value), 30)
refs = reduce(lambda a, b: a & b, [count(value[i:i+30])
for i in rx])
else:
refs = db(id.belongs(value)).select(id)
return refs and ', '.join(
_fieldformat(self.ref, *x.id <http://x.id>*) for x in value) or
''
It seems that x is already the id of the record. I changed
return refs and ', '.join(
_fieldformat(self.ref, *x.id <http://x.id>*) for x in value) or
''
to
return refs and ', '.join(
_fieldformat(self.ref, *x*) for x in value) or ''
and everything works as expected. Sorry, I had not enough time to analyze
the whole code - maybe there are side effects which I did not find.
Regards, Martin
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.