[Zodb-checkins] SVN: ZODB/trunk/src/ Merged the hannosch-ibroken branch which provides an interface for

Jim Fulton jim at zope.com
Fri Jan 8 10:29:51 EST 2010


Log message for revision 107799:
  Merged the hannosch-ibroken branch which provides an interface for
  broken objects.
  

Changed:
  U   ZODB/trunk/src/CHANGES.txt
  U   ZODB/trunk/src/ZODB/broken.py
  U   ZODB/trunk/src/ZODB/interfaces.py
  U   ZODB/trunk/src/ZODB/tests/testBroken.py

-=-
Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt	2010-01-08 15:29:48 UTC (rev 107798)
+++ ZODB/trunk/src/CHANGES.txt	2010-01-08 15:29:50 UTC (rev 107799)
@@ -5,6 +5,11 @@
 3.10.0a1 (2009-12-??)
 =====================
 
+New Features
+------------
+
+- Broken objects now provide the IBroken interface.
+
 Bugs Fixed
 ----------
 

Modified: ZODB/trunk/src/ZODB/broken.py
===================================================================
--- ZODB/trunk/src/ZODB/broken.py	2010-01-08 15:29:48 UTC (rev 107798)
+++ ZODB/trunk/src/ZODB/broken.py	2010-01-08 15:29:50 UTC (rev 107799)
@@ -19,6 +19,10 @@
 import sys
 import persistent
 
+import zope.interface
+
+import ZODB.interfaces
+
 broken_cache = {}
 
 class Broken(object):
@@ -92,6 +96,8 @@
          >>> broken_cache.clear()
        """
 
+    zope.interface.implements(ZODB.interfaces.IBroken)
+
     __Broken_state__ = __Broken_initargs__ = None
 
     __name__ = 'broken object'

Modified: ZODB/trunk/src/ZODB/interfaces.py
===================================================================
--- ZODB/trunk/src/ZODB/interfaces.py	2010-01-08 15:29:48 UTC (rev 107798)
+++ ZODB/trunk/src/ZODB/interfaces.py	2010-01-08 15:29:50 UTC (rev 107799)
@@ -1217,6 +1217,32 @@
         """
 
 
+class IBroken(Interface):
+    """Broken objects are placeholders for objects that can no longer be
+    created because their class has gone away.
+
+    They cannot be modified, but they retain their state. This allows them to
+    be rebuild should the missing class be found again.
+
+    A broken object's __class__ can be used to determine the original
+    class' name (__name__) and module (__module__).
+
+    The original object's state and initialization arguments are
+    available in broken object attributes to aid analysis and
+    reconstruction.
+
+    """
+
+    def __setattr__(name, value):
+        """You cannot modify broken objects. This will raise a
+        ZODB.broken.BrokenModified exception.
+        """
+
+    __Broken_newargs__ = Attribute("Arguments passed to __new__.")
+    __Broken_initargs__ = Attribute("Arguments passed to __init__.")
+    __Broken_state__ = Attribute("Value passed to __setstate__.")
+
+
 class BlobError(Exception):
     pass
 

Modified: ZODB/trunk/src/ZODB/tests/testBroken.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/testBroken.py	2010-01-08 15:29:48 UTC (rev 107798)
+++ ZODB/trunk/src/ZODB/tests/testBroken.py	2010-01-08 15:29:50 UTC (rev 107799)
@@ -71,6 +71,12 @@
     >>> a3.__Broken_state__
     {'x': 1}
 
+    Broken objects provide an interface:
+
+    >>> from ZODB.interfaces import IBroken
+    >>> IBroken.providedBy(a3)
+    True
+
     Let's clean up:
 
     >>> db.close()



More information about the Zodb-checkins mailing list