My patch 5. is the most serious.  That bug causes an 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.

Patch 2. is also pretty serious. Maybe this has been addressed
somewhere, but I am seeing that html.py tries
to return XML() which causes an Exception:
#   File "C:\Program Files (x86)\Google\google_appengine\google
\appengine\api\datastore_types.py", line 1323, in ValidateProperty
#    'Unsupported type for property %s: %s' % (name, v.__class__))
#       BadValueError: Unsupported type for property success_path:

I'll see what I can do about creating (Mercurial (?)) patch files.
That is new to me but I suppose a blessing to learn...


On Feb 6, 12:35 am, Massimo Di Pierro <[email protected]>
wrote:
> Can you please send me all the changes as a patch file to the latest
> dal.py? I am lost because of google groups breaks indentation.
>
> On Feb 5, 9:40 pm, dlypka <[email protected]> wrote:
>
>
>
>
>
>
>
> > 6. in dal.py class Table around line 5900:
>
> >     def _drop(self, mode = ''):
> >         return self._db._adapter._drop(self, mode)
>
> >     def drop(self, mode = ''):
> >         return self._db._adapter._drop(self, mode) # dlypka patch.
> > was: self._db._adapter.drop(self,mode)
>
> > On Feb 5, 10:36 pm, dlypka <[email protected]> wrote:
>
> > > 5. 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:'):  # dlypka patch to move this
> > > 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]
>
> > > On Feb 5, 11:21 am, dlypka <[email protected]> wrote:
>
> > > > More issues
> > > > 1. # dlypka Mod in dal.py: had to move this try .. except up here in
> > > > front of class NoSQLAdapter because gae is needed in class
> > > > NoSQLAdapter
> > > > try:
> > > >     from new import classobj
> > > >     from google.appengine.ext import db as gae
> > > >     from google.appengine.api import namespace_manager
> > > >     # from google.appengine.api.datastore_types import Key  ### why
> > > > was this needed????
> > > >     from google.appengine.ext.db.polymodel import PolyModel
> > > >     drivers.append('gae')
> > > > except ImportError:
> > > >     pass
>
> > > > class NoSQLAdapter(BaseAdapter):
>
> > > > 2. html.py line 265
> > > >     return rewrite.filter_out(url, env) # dlypka patch. Was
> > > > XML(rewrite.filter_out(url, env))
> > > > # XML() causes Exception:
> > > > #   File "C:\Program Files (x86)\Google\google_appengine\google
> > > > \appengine\api\datastore_types.py", line 1323, in ValidateProperty
> > > > #    'Unsupported type for property %s: %s' % (name, v.__class__))
> > > > #       BadValueError: Unsupported type for property success_path:
> > > > <class 'gluon.html.XML'>
>
> > > > 3. class GAENoSQLAdapter(NoSQLAdapter):
> > > >     uploads_in_blob = True
> > > >     types = {}
>
> > > >     def file_exists(self, filename): pass
> > > >     def file_open(self, filename, mode='rb', lock=True): pass
> > > >     def file_close(self, fileobj, unlock=True): pass
>
> > > >     def __init__(self,db,uri,pool_size=0,folder=None,db_codec
> > > > ='UTF-8',
> > > >                  credential_decoder=(lambda x:x)):  # dlypka patch:
> > > > added brackets around lambda - syntax error
> > > >         self.types.update({
>
> > > > 4.     def insert(self,table,fields):
> > > >         dfields=dict((f.name,self.represent(v,f.type)) for f,v in
> > > > fields)
> > > >         # table._db['_lastsql'] = self._insert(table,fields)
> > > >         tmp = table._tableobj(**dfields)
> > > >         tmp.put()
> > > >         table._db['_last_reference'] = tmp # dlypka patched based on
> > > > June 27/2010 mod in the trunk
> > > >         rid = Reference(tmp.key().id())
> > > >         (rid._table, rid._record) = (table, None)
> > > >         return rid

Reply via email to