There's a change to the delete behavior in the GAE SDK 1.3.3 which is
incompatible with AEP.

For the moment, the SDK raises an IndexError when you try to delete
the result a query that returns nothing.

This patch is bit of a hack to bypass the delete call when the query
has no result.  Also, it was originally wrapping queries in a list,
which I don't believe is necessary, and would skip pre & post deletes
when passing a query.

--- common/appenginepatch/appenginepatcher/patch.py     (current AEP)
+++ common/appenginepatch/appenginepatcher/patch.py     (new)
@@ -620,15 +620,21 @@
     if not hasattr(db.delete, 'patched'):
         old_db_delete = db.delete
         def delete(models, *args, **kwargs):
-            if not isinstance(models, (list, tuple)):
+            if not isinstance(models, (list, tuple, db.Query)):
                 items = (models,)
             else:
                 items = models
+            have_something = False
             for item in items:
+                if item is None:
+                    continue
                 if not isinstance(item, db.Model):
                     continue
+                have_something = True
                 signals.pre_delete.send(sender=item.__class__,
instance=item)
-            result = old_db_delete(models, *args, **kwargs)
+            result = None
+            if have_something:
+                result = old_db_delete(models, *args, **kwargs)
             for item in items:
                 if not isinstance(item, db.Model):
                     continue

-- 
You received this message because you are subscribed to the Google Groups 
"app-engine-patch" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/app-engine-patch?hl=en.

Reply via email to