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