X-Git-Url: https://git.jsancho.org/?p=mojodb.git;a=blobdiff_plain;f=cursor.py;fp=cursor.py;h=eec8b65e71d865e7b0bc6fd1112d11cd4d4f06f1;hp=6246872c35ab3c66c2d1d5c32c949deb22565864;hb=8893f5128b8e8790f186c8bf354a3bb721d69bcb;hpb=aa509ddc8574e0a5220c94a2b72f4d5a798d6e8a diff --git a/cursor.py b/cursor.py index 6246872..eec8b65 100644 --- a/cursor.py +++ b/cursor.py @@ -19,7 +19,6 @@ # ############################################################################## -import msgpack class Cursor(object): def __init__(self, collection, spec=None, fields=None, **kwargs): @@ -32,6 +31,8 @@ class Cursor(object): self.Constraint = collection.database.connection.Constraint self.Literal = collection.database.connection.Literal + self.serializer = collection.database.connection.serializer + self.collection = collection self.spec = spec if self.collection.exists(): @@ -116,7 +117,7 @@ class Cursor(object): field_type = 'number' else: field_type = 'value' - field_value = msgpack.dumps(field_value) + field_value = self.serializer.dumps(field_value) fields = [self.Field(table_field, 'id')] tables = [table_field] @@ -139,11 +140,11 @@ class Cursor(object): else: document = {} if '_id' in self.fields: - document['_id'] = msgpack.loads(res[0]) + document['_id'] = self.serializer.loads(res[0]) fields_without_id = filter(lambda x: x != '_id', self.fields) for i in xrange(len(fields_without_id)): if not res[i + 1] is None: - document[fields_without_id[i]] = msgpack.loads(res[i + 1]) + document[fields_without_id[i]] = self.serializer.loads(res[i + 1]) return document else: return None