1. Matt McDonald
  2. djangoappengine

Commits

Waldemar Kornewald  committed 32196b6

fixed cursors (now there's a public cursor API)

  • Participants
  • Parent commits b76c5f8
  • Branches default

Comments (0)

Files changed (4)

File db/utils.py

View file
-from google.appengine.datastore.datastore_pb import CompiledCursor
-import base64
+from google.appengine.datastore.datastore_query import Cursor
 
 def get_cursor(queryset):
     # Evaluate QuerySet
     len(queryset)
     cursor = getattr(queryset.query, '_gae_cursor', None)
-    return base64.urlsafe_b64encode(cursor.Encode())
+    return Cursor.to_websafe_string(cursor)
 
 def set_cursor(queryset, start=None, end=None):
     if start is not None:
-        start = base64.urlsafe_b64decode(str(start))
-        start = CompiledCursor(start)
+        start = Cursor.from_websafe_string(start)
         queryset.query._gae_start_cursor = start
     if end is not None:
-        end = base64.urlsafe_b64decode(str(end))
-        end = CompiledCursor(end)
+        end = Cursor.from_websafe_string(end)
         queryset.query._gae_end_cursor = end
     # Evaluate QuerySet
     len(queryset)

File tests/field_options.py

View file
         # TODO: check db_column option
         # TODO: change the primary key and check if a new instance with the
         # changed primary key will be saved (not in this test class)
-        

File tests/filter.py

View file
-from .testmodels import FieldsWithOptionsModel, EmailModel, DateTimeModel, OrderedModel
-from ..db.utils import get_cursor
-import datetime, time
-from django.test import TestCase
+from ..db.utils import get_cursor, set_cursor
+from .testmodels import FieldsWithOptionsModel, EmailModel, DateTimeModel, \
+    OrderedModel, BlobModel
 from django.db.models import Q
 from django.db.utils import DatabaseError
-from djangoappengine.db.utils import set_cursor
-from djangoappengine.tests.testmodels import BlobModel
+from django.test import TestCase
+from django.utils import unittest
 from google.appengine.api.datastore import Get, Key
+import datetime
+import time
 
 class FilterTest(TestCase):
     floats = [5.3, 2.6, 9.1, 1.58]

File tests/testmodels.py

View file
     floating_point = models.FloatField()
     boolean = models.BooleanField()
     null_boolean = models.NullBooleanField()
-    text = models.CharField(max_length=3)
+    text = models.CharField(max_length=32)
     email = models.EmailField()
     comma_seperated_integer = models.CommaSeparatedIntegerField(max_length=10)
     ip_address = models.IPAddressField()