removing longs and fixing iterators
This commit is contained in:
@@ -64,7 +64,7 @@ class MinTimeUUID(BaseQueryFunction):
|
||||
def to_database(self, val):
|
||||
epoch = datetime(1970, 1, 1, tzinfo=val.tzinfo)
|
||||
offset = epoch.tzinfo.utcoffset(epoch).total_seconds() if epoch.tzinfo else 0
|
||||
return long(((val - epoch).total_seconds() - offset) * 1000)
|
||||
return int(((val - epoch).total_seconds() - offset) * 1000)
|
||||
|
||||
def update_context(self, ctx):
|
||||
ctx[str(self.context_id)] = self.to_database(self.value)
|
||||
@@ -91,7 +91,7 @@ class MaxTimeUUID(BaseQueryFunction):
|
||||
def to_database(self, val):
|
||||
epoch = datetime(1970, 1, 1, tzinfo=val.tzinfo)
|
||||
offset = epoch.tzinfo.utcoffset(epoch).total_seconds() if epoch.tzinfo else 0
|
||||
return long(((val - epoch).total_seconds() - offset) * 1000)
|
||||
return int(((val - epoch).total_seconds() - offset) * 1000)
|
||||
|
||||
def update_context(self, ctx):
|
||||
ctx[str(self.context_id)] = self.to_database(self.value)
|
||||
|
||||
@@ -368,7 +368,7 @@ class AbstractQuerySet(object):
|
||||
|
||||
def first(self):
|
||||
try:
|
||||
return iter(self).next()
|
||||
return six.next(iter(self))
|
||||
except StopIteration:
|
||||
return None
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from datetime import datetime, timedelta
|
||||
import json
|
||||
from uuid import uuid4
|
||||
import six
|
||||
|
||||
from cqlengine import Model, ValidationError
|
||||
from cqlengine import columns
|
||||
@@ -22,7 +23,7 @@ class JsonTestColumn(columns.Column):
|
||||
|
||||
def to_python(self, value):
|
||||
if value is None: return
|
||||
if isinstance(value, basestring):
|
||||
if isinstance(value, six.string_types):
|
||||
return json.loads(value)
|
||||
else:
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user