[Checkins] SVN: mongopersist/trunk/ Bug: Due to ``UserDict`` implementing ``dict`` comparison semantics, any

Stephen Richter cvs-admin at zope.org
Wed Feb 6 02:41:40 UTC 2013


Log message for revision 129142:
  Bug: Due to ``UserDict`` implementing ``dict`` comparison semantics, any
  empty ``MongoContainer`` would equate to another empty one. This behavior
  would cause object changes to not be properly recognzed by the mongo data
  manager. The implemented solution is to implement default object comparison
  behavior for mongo containers.
  
  Get ready for release.
  
  

Changed:
  U   mongopersist/trunk/CHANGES.txt
  U   mongopersist/trunk/setup.py
  U   mongopersist/trunk/src/mongopersist/zope/container.py
  U   mongopersist/trunk/src/mongopersist/zope/tests/test_container.py

-=-
Modified: mongopersist/trunk/CHANGES.txt
===================================================================
--- mongopersist/trunk/CHANGES.txt	2013-02-05 20:41:42 UTC (rev 129141)
+++ mongopersist/trunk/CHANGES.txt	2013-02-06 02:41:39 UTC (rev 129142)
@@ -2,17 +2,21 @@
 CHANGES
 =======
 
-0.7.4 (unreleased)
+0.7.4 (2013-02-05)
 ------------------
 
-- Nothing changed yet.
+- Bug: Due to ``UserDict`` implementing ``dict`` comparison semantics, any
+  empty ``MongoContainer`` would equate to another empty one. This behavior
+  would cause object changes to not be properly recognzed by the mongo data
+  manager. The implemented solution is to implement default object comparison
+  behavior for mongo containers.
 
 
 0.7.3 (2013-01-29)
 ------------------
 
-- update to latest package versions
-  biggest change: ``pymongo`` does not reexport ``objectid`` and ``dbref``
+- Feature: Update to latest package versions, specifically pymongo 2.4.x. In
+  this release, ``pymongo`` does not reexport ``objectid`` and ``dbref``.
 
 0.7.2 (2012-04-19)
 ------------------

Modified: mongopersist/trunk/setup.py
===================================================================
--- mongopersist/trunk/setup.py	2013-02-05 20:41:42 UTC (rev 129141)
+++ mongopersist/trunk/setup.py	2013-02-06 02:41:39 UTC (rev 129142)
@@ -9,7 +9,7 @@
 
 setup (
     name='mongopersist',
-    version='0.7.4.dev0',
+    version='0.7.4',
     author = "Stephan Richter",
     author_email = "stephan.richter at gmail.com",
     description = "Mongo Persistence Backend",

Modified: mongopersist/trunk/src/mongopersist/zope/container.py
===================================================================
--- mongopersist/trunk/src/mongopersist/zope/container.py	2013-02-05 20:41:42 UTC (rev 129141)
+++ mongopersist/trunk/src/mongopersist/zope/container.py	2013-02-06 02:41:39 UTC (rev 129142)
@@ -175,6 +175,12 @@
         self._locate(obj, doc)
         return obj
 
+    def __cmp__(self, other):
+        # UserDict implements the semantics of implementing comparison of
+        # items to determine equality, which is not what we want for a
+        # container, so we revert back to the default object comparison.
+        return cmp(id(self), id(other))
+
     def __getitem__(self, key):
         filter = self._m_get_items_filter()
         filter[self._m_mapping_key] = key
@@ -195,7 +201,7 @@
         # its oid.
         if value._p_oid is None:
             self._m_jar.insert(value)
-        # When the key is None, we use the object is as name.
+        # When the key is None, we use the object id as name.
         if key is None:
             key = unicode(value._p_oid.id)
         # We want to be as close as possible to using the Zope semantics.

Modified: mongopersist/trunk/src/mongopersist/zope/tests/test_container.py
===================================================================
--- mongopersist/trunk/src/mongopersist/zope/tests/test_container.py	2013-02-05 20:41:42 UTC (rev 129141)
+++ mongopersist/trunk/src/mongopersist/zope/tests/test_container.py	2013-02-06 02:41:39 UTC (rev 129142)
@@ -74,7 +74,10 @@
     def __init__(self, name):
         self.name = name
 
+    def __repr__(self):
+        return '<%s %s>' %(self.__class__.__name__, self.name)
 
+
 def doctest_Campaign():
     """MongoContainer: basic
 
@@ -102,7 +105,7 @@
       >>> dm.root['c'].keys()
       [u'one']
       >>> dm.root['c'][u'one']
-      <mongopersist.zope.tests.test_container.Campaign object at 0x001122>
+      <Campaign one>
 
       >>> dm.root['c']['one'].__parent__
       <mongopersist.zope.tests.test_container.Campaigns object at 0x001122>
@@ -164,15 +167,15 @@
 
     Check adding of more objects:
 
-      >>> dm.root['c'][u'roy'] = Campaign(u'Roy')
+      >>> dm.root['c'][u'1'] = c1 = Campaign(u'One')
       ContainerModifiedEvent: <...Campaigns ...>
-      >>> dm.root['c'][u'adam'] = Campaign(u'Adam')
+      >>> dm.root['c'][u'2'] = c2 = Campaign(u'Two')
       ContainerModifiedEvent: <...Campaigns ...>
-      >>> dm.root['c'][u'marius'] = Campaign(u'Marius')
+      >>> dm.root['c'][u'3'] = Campaign(u'Three')
       ContainerModifiedEvent: <...Campaigns ...>
 
       >>> sorted(dm.root['c'].keys())
-      [u'adam', u'marius', u'roy']
+      [u'1', u'2', u'3']
     """
 
 



More information about the checkins mailing list