[Checkins] SVN: persistent/trunk/persistent/ Merge from 'tseaver-python_picklecache-2' branch:

Tres Seaver tseaver at palladion.com
Tue Sep 27 12:51:45 EST 2011


Log message for revision 122979:
  Merge from 'tseaver-python_picklecache-2' branch:
  
  ------------------------------------------------------------------------
  r122975 | tseaver | 2011-09-27 13:31:54 -0400 (Tue, 27 Sep 2011) | 1 line
  
  Move to match order defined in IPickleCache.
  ------------------------------------------------------------------------
  r122974 | tseaver | 2011-09-27 13:31:06 -0400 (Tue, 27 Sep 2011) | 1 line
  
  Tolerate being handed irrelevant arguments.
  ------------------------------------------------------------------------
  r122973 | tseaver | 2011-09-27 13:31:05 -0400 (Tue, 27 Sep 2011) | 1 line
  
  Enable 'Timestamp' fallback to 'timestamp' when extension unavailable.
  ------------------------------------------------------------------------
  r122972 | tseaver | 2011-09-27 13:31:04 -0400 (Tue, 27 Sep 2011) | 3 lines
  
  Don't raise KeyError for OID collision w/ same value object.
  
  Also, implement stub of 'update_object_size_estimation'.
  ------------------------------------------------------------------------
  r122971 | tseaver | 2011-09-27 13:31:03 -0400 (Tue, 27 Sep 2011) | 1 line
  
  Document additional picklecache methods.
  

Changed:
  U   persistent/trunk/persistent/__init__.py
  U   persistent/trunk/persistent/interfaces.py
  U   persistent/trunk/persistent/picklecache.py
  U   persistent/trunk/persistent/pyPersistence.py
  U   persistent/trunk/persistent/tests/test_pypicklecache.py

-=-
Modified: persistent/trunk/persistent/__init__.py
===================================================================
--- persistent/trunk/persistent/__init__.py	2011-09-27 17:47:31 UTC (rev 122978)
+++ persistent/trunk/persistent/__init__.py	2011-09-27 17:51:45 UTC (rev 122979)
@@ -39,6 +39,13 @@
 except ImportError:
     from picklecache import PickleCache
 
+try:
+    import TimeStamp
+except ImportError:
+    import timestamp as TimeStamp
+    import sys
+    sys.modules['persistent.TimeStamp'] = sys.modules['persistent.timestamp']
+
 if _HAVE_CPERSISTENCE:
     # Make an interface declaration for Persistent, if zope.interface
     # is available.  XXX that the pyPersistent version already does this?

Modified: persistent/trunk/persistent/interfaces.py
===================================================================
--- persistent/trunk/persistent/interfaces.py	2011-09-27 17:47:31 UTC (rev 122978)
+++ persistent/trunk/persistent/interfaces.py	2011-09-27 17:51:45 UTC (rev 122979)
@@ -537,6 +537,16 @@
             remove it from the ring.
         """
 
+    def debug_info():
+        """Return debugging data about objects in the cache.
+
+        o Return a sequence of tuples, (oid, refcount, typename, state).
+        """
+
+    def update_object_size_estimation(oid, new_size):
+        """Update the cache's size estimation for 'oid', if known to the cache.
+        """
+
     cache_size = Attribute(u'Target size of the cache')
     cache_drain_resistance = Attribute(u'Factor for draining cache below '
                                         u'target size')

Modified: persistent/trunk/persistent/picklecache.py
===================================================================
--- persistent/trunk/persistent/picklecache.py	2011-09-27 17:47:31 UTC (rev 122978)
+++ persistent/trunk/persistent/picklecache.py	2011-09-27 17:51:45 UTC (rev 122979)
@@ -65,7 +65,8 @@
             raise ValueError('OID must be string: %s' % oid)
         # XXX
         if oid in self.persistent_classes or oid in self.data:
-            raise KeyError('Duplicate OID: %s' % oid)
+            if self.data[oid] is not value:
+                raise KeyError('Duplicate OID: %s' % oid)
         if type(value) is type:
             self.persistent_classes[oid] = value
         else:
@@ -226,6 +227,11 @@
                             ))
         return result
 
+    def update_object_size_estimation(self, oid, new_size):
+        """ See IPickleCache.
+        """
+        pass
+
     cache_size = property(lambda self: self.target_size)
     cache_drain_resistance = property(lambda self: self.drain_resistance)
     cache_non_ghost_count = property(lambda self: self.non_ghost_count)
@@ -254,4 +260,3 @@
                     break
         elif oid in self.persistent_classes:
             del self.persistent_classes[oid]
-

Modified: persistent/trunk/persistent/pyPersistence.py
===================================================================
--- persistent/trunk/persistent/pyPersistence.py	2011-09-27 17:47:31 UTC (rev 122978)
+++ persistent/trunk/persistent/pyPersistence.py	2011-09-27 17:51:45 UTC (rev 122979)
@@ -80,7 +80,7 @@
     __slots__ = ('__jar', '__oid', '__serial', '__flags', '__size')
     implements(IPersistent)
 
-    def __new__(cls):
+    def __new__(cls, *args, **kw):
         inst = super(Persistent, cls).__new__(cls)
         inst.__jar = None
         inst.__oid = None

Modified: persistent/trunk/persistent/tests/test_pypicklecache.py
===================================================================
--- persistent/trunk/persistent/tests/test_pypicklecache.py	2011-09-27 17:47:31 UTC (rev 122978)
+++ persistent/trunk/persistent/tests/test_pypicklecache.py	2011-09-27 17:51:45 UTC (rev 122979)
@@ -92,6 +92,7 @@
         cache = self._makeOne()
         original = self._makePersist()
         cache['original'] = original
+        cache['original'] = original # doesn't raise
         duplicate = self._makePersist()
 
         try:



More information about the checkins mailing list