Description:
Fix issue #29 in gae2django
Please review this at http://codereview.appspot.com/5686061/
Affected files:
M .hgignore
M gae2django/gaeapi/appengine/ext/db.py
Index: .hgignore
===================================================================
--- a/.hgignore
+++ b/.hgignore
@@ -10,4 +10,7 @@
examples/rietveld/rietveld.hg
# ignore local copies of django
-django/
\ No newline at end of file
+django/
+
+*.pyc
+*.egg-info
Index: gae2django/gaeapi/appengine/ext/db.py
===================================================================
--- a/gae2django/gaeapi/appengine/ext/db.py
+++ b/gae2django/gaeapi/appengine/ext/db.py
@@ -38,6 +38,7 @@
def __init__(self, *args, **kwds):
super(Query, self).__init__(*args, **kwds)
self._listprop_filter = None
+ self.keys_only = False
def filter(self, *args, **kwds):
if kwds:
@@ -106,9 +107,18 @@
matched = False
break
if matched:
+ if self.keys_only:
+ yield obj.pk
+ else:
+ yield obj
+ else:
+ if self.keys_only:
+ yield obj.pk
+ else:
yield obj
- else:
- yield obj
+
+ def cursor(self):
+ return base64.b64encode(cPickle.dumps(self))
class BaseManager(manager.Manager):
@@ -435,8 +445,10 @@
return cls._meta.db_table
@classmethod
- def all(cls):
- return cls.objects.all()
+ def all(cls, keys_only=False):
+ q = cls.objects.all()
+ q.keys_only = keys_only
+ return q
@classmethod
def properties(cls):