1. Andy Mikhailenko
  2. monk


Andy Mikhailenko  committed b465405

Upgraded to pymongo 2.2 (some of its modules were moved to the bson package).

  • Participants
  • Parent commits 15d594a
  • Branches default

Comments (0)

Files changed (5)


View file
 # Maintainer: Andrey Mikhaylenko <neithere at gmail dot com>
 pkgdesc="A lightweight schema/query framework for MongoDB"
 build() {
    cd "${srcdir}/monk-${pkgver}"

File monk/__init__.py

View file
 .. _pymongo: http://api.mongodb.org/python/current/
-__version__ = '0.5.0'
+__version__ = '0.5.1'
 # remember to also update:

File monk/modeling.py

View file
     collection.save(dict(item))  # also validation, transformation, etc.
+from __future__ import unicode_literals
 from functools import partial
-from pymongo import dbref
+from bson import DBRef
 from monk import manipulation
 from monk import validation
         if _id is None:
             return None
-            return dbref.DBRef(self.collection, _id)
+            return DBRef(self.collection, _id)
     def remove(self, db):
     for key, value in data.iteritems():
         if isinstance(value, dict):
             yield key, dict(_db_to_dict_pairs(spec.get(key, {}), value, db))
-        elif isinstance(value, dbref.DBRef):
+        elif isinstance(value, DBRef):
             obj = db.dereference(value)
             cls = spec.get(key, dict)
             yield key, cls(obj, _id=obj['_id']) if obj else None
         if isinstance(value, dict):
             if '_id' in value:
                 collection = spec[key].collection
-                yield key, dbref.DBRef(collection, value['_id'])
+                yield key, DBRef(collection, value['_id'])
                 yield key, dict(_dict_to_db_pairs(spec.get(key, {}), value))

File unittests/test_modeling.py

View file
 import datetime
 import pymongo
-from pymongo.objectid import ObjectId
-from pymongo.dbref import DBRef
+from bson import ObjectId, DBRef
 import pytest
 from monk import modeling

File unittests/test_validation.py

View file
 import datetime
+import bson
 import pymongo
-import pymongo.binary
-import pymongo.code
-import pymongo.dbref
-import pymongo.objectid
 import pytest
 from monk.validation import (
         validate_structure_spec({'foo': list})
         validate_structure_spec({'foo': unicode})
         validate_structure_spec({'foo': datetime.datetime})
-        validate_structure_spec({'foo': pymongo.binary.Binary})
-        validate_structure_spec({'foo': pymongo.code.Code})
-        validate_structure_spec({'foo': pymongo.objectid.ObjectId})
-        validate_structure_spec({'foo': pymongo.dbref.DBRef})
+        validate_structure_spec({'foo': bson.Binary})
+        validate_structure_spec({'foo': bson.Code})
+        validate_structure_spec({'foo': bson.ObjectId})
+        validate_structure_spec({'foo': bson.DBRef})
     def test_correct_structures(self):
         # foo is of given type
             validate_structure({'a': datetime.datetime}, {'a': 123})
     def test_objectid(self):
-        validate_structure({'a': pymongo.objectid.ObjectId}, {'a': None})
-        validate_structure({'a': pymongo.objectid.ObjectId},
-                                {'a': pymongo.objectid.ObjectId()})
+        validate_structure({'a': bson.ObjectId}, {'a': None})
+        validate_structure({'a': bson.ObjectId}, {'a': bson.ObjectId()})
     def test_dbref(self):
-        validate_structure({'a': pymongo.dbref.DBRef}, {'a': None})
-        validate_structure({'a': pymongo.dbref.DBRef},
-                           {'a': pymongo.dbref.DBRef('a', 'b')})
+        validate_structure({'a': bson.DBRef}, {'a': None})
+        validate_structure({'a': bson.DBRef},
+                           {'a': bson.DBRef('a', 'b')})
     def test_valid_document(self):
         "a complex document"