Commits

Andy Mikhailenko  committed b465405

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

  • Participants
  • Parent commits 15d594a

Comments (0)

Files changed (5)

 # Maintainer: Andrey Mikhaylenko <neithere at gmail dot com>
 pkgname=python2-monk
-pkgver=0.3.0
+pkgver=0.5.1
 pkgrel=1
 pkgdesc="A lightweight schema/query framework for MongoDB"
 arch=(any)
 options=(!emptydirs)
 install=
 source=(http://pypi.python.org/packages/source/m/monk/monk-${pkgver}.tar.gz)
-md5sums=('335d5a0f380f2672de8e7be504fbccd6')
+md5sums=('b743be7d0ce5387242fff5390149217a')
 
 build() {
    cd "${srcdir}/monk-${pkgver}"

File monk/__init__.py

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

File monk/modeling.py

     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
         else:
-            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'])
             else:
                 yield key, dict(_dict_to_db_pairs(spec.get(key, {}), value))
         else:

File unittests/test_modeling.py

 """
 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

 ================
 """
 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"