What steps will reproduce the problem? 1. exception when
creating a table which has
native GAE properties such as gae.ReferenceProperty() because that is
not a string (it is not in quotes)
For example, this will crash:
db.Field('seq','integer'), # OK because
'integer' is a string
db.Field('gaeRef', gae.ReferenceProperty()), #
crashes here because expression gae.ReferenceProperty() is not a
string. My suggested patch is to move the check for gae properties
ahead of the string check. What is the expected output? What do you see instead? What version of the product are you using? On what operating system? Please provide any additional information below. In dal.py:
class NoSQLAdapter(BaseAdapter):
def represent(self, obj, fieldtype):
if type(obj) in (types.LambdaType, types.FunctionType):
obj = obj()
if isinstance(fieldtype, SQLCustomType):
return fieldtype.encoder(obj)
if isinstance(obj, (Expression, Field)):
raise SyntaxError, "non supported on GAE"
if 'gae' in globals():
if isinstance(fieldtype, gae.Property):
return obj
if fieldtype.startswith('list:'): # patch: move this if stmt
to be AFTER the if 'gae' clause because fieldtype may not necessarily
be a string
if not obj:
obj = []
if not isinstance(obj, (list, tuple)):
obj = [obj]
From dly...@gmail.com on February 06, 2011 06:04:49
What steps will reproduce the problem? 1. exception when creating a table which has native GAE properties such as gae.ReferenceProperty() because that is not a string (it is not in quotes) For example, this will crash: db.Field('seq','integer'), # OK because 'integer' is a string db.Field('gaeRef', gae.ReferenceProperty()), # crashes here because expression gae.ReferenceProperty() is not a string. My suggested patch is to move the check for gae properties ahead of the string check. What is the expected output? What do you see instead? What version of the product are you using? On what operating system? Please provide any additional information below. In dal.py: class NoSQLAdapter(BaseAdapter): def represent(self, obj, fieldtype): if type(obj) in (types.LambdaType, types.FunctionType): obj = obj() if isinstance(fieldtype, SQLCustomType): return fieldtype.encoder(obj) if isinstance(obj, (Expression, Field)): raise SyntaxError, "non supported on GAE" if 'gae' in globals(): if isinstance(fieldtype, gae.Property): return obj if fieldtype.startswith('list:'): # patch: move this if stmt to be AFTER the if 'gae' clause because fieldtype may not necessarily be a string if not obj: obj = [] if not isinstance(obj, (list, tuple)): obj = [obj]
Original issue: http://code.google.com/p/web2py/issues/detail?id=182