alfonsodg / demo-web2py

Apache License 2.0
0 stars 0 forks source link

Filtering by GAE properties (especially by UserProperty) doesn't work #161

Closed alfonsodg closed 10 years ago

alfonsodg commented 10 years ago

From roman.imankulov on January 22, 2011 05:22:52

The issue can be easily reproduced with the following code snippet (I suppose it's a controller):

def test(): from gluon.contrib.gql import gae from google.appengine.api import users

define tables

db.define_table('profile',
      Field('user', gae.UserProperty()),
      Field('alias'),
)
db(db.profile.id > 0).delete()
# insert data
user = users.User(email='info@example.com')
profile_id = db.profile.insert(user=user, alias='Mr. Alias')
# select data
profile = db(db.profile.user==user).select().first()
return "Profile: %s aka %s" % (profile.user, profile.alias)

I expect to get "Profile: info@example.com aka Mr. Alias" but I'm getting instead Internal Error with traceback:

Traceback (most recent call last): File ".../web2py/gluon/restricted.py", line 188, in restricted exec ccode in environment File ".../web2py/applications/myapp/controllers/default.py:test", line 103, in File ".../web2py/gluon/globals.py", line 95, in self._caller = lambda f: f() File ".../web2py/applications/myapp/controllers/default.py:test", line 16, in test File ".../web2py/gluon/dal.py", line 3913, in insert return self._db._adapter.insert(self,self._listify(fields)) File ".../web2py/gluon/dal.py", line 2763, in insert dfields=dict((f.name,self.represent(v,f.type)) for f,v in fields) File ".../web2py/gluon/dal.py", line 2763, in dfields=dict((f.name,self.represent(v,f.type)) for f,v in fields) File ".../web2py/gluon/dal.py", line 2316, in represent if fieldtype.startswith('list:'): AttributeError: 'UserProperty' object has no attribute 'startswith'

The simple patch in the attachment eliminates the issue, but I'm not sure about possible side-effects. Can you please review and incorporate?

Attachment: dal.diff

Original issue: http://code.google.com/p/web2py/issues/detail?id=163

alfonsodg commented 10 years ago

From massimo....@gmail.com on January 28, 2011 07:07:28

Thanks Roman

Status: Fixed