[Zodb-checkins] SVN: ZODB/branches/hannosch-ibroken/src/ Broken objects now provide the IBroken interface.

Hanno Schlichting hannosch at hannosch.eu
Thu Dec 31 14:54:00 EST 2009


Log message for revision 107467:
  Broken objects now provide the IBroken interface.
  

Changed:
  U   ZODB/branches/hannosch-ibroken/src/CHANGES.txt
  U   ZODB/branches/hannosch-ibroken/src/ZODB/broken.py
  U   ZODB/branches/hannosch-ibroken/src/ZODB/interfaces.py
  U   ZODB/branches/hannosch-ibroken/src/ZODB/tests/testBroken.py

-=-
Modified: ZODB/branches/hannosch-ibroken/src/CHANGES.txt
===================================================================
--- ZODB/branches/hannosch-ibroken/src/CHANGES.txt	2009-12-31 18:56:40 UTC (rev 107466)
+++ ZODB/branches/hannosch-ibroken/src/CHANGES.txt	2009-12-31 19:54:00 UTC (rev 107467)
@@ -5,6 +5,11 @@
 3.10.0a1 (2009-12-??)
 =====================
 
+New Features
+------------
+
+- Broken objects now provide the IBroken interface.
+
 Bugs Fixed
 ----------
 

Modified: ZODB/branches/hannosch-ibroken/src/ZODB/broken.py
===================================================================
--- ZODB/branches/hannosch-ibroken/src/ZODB/broken.py	2009-12-31 18:56:40 UTC (rev 107466)
+++ ZODB/branches/hannosch-ibroken/src/ZODB/broken.py	2009-12-31 19:54:00 UTC (rev 107467)
@@ -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/branches/hannosch-ibroken/src/ZODB/interfaces.py
===================================================================
--- ZODB/branches/hannosch-ibroken/src/ZODB/interfaces.py	2009-12-31 18:56:40 UTC (rev 107466)
+++ ZODB/branches/hannosch-ibroken/src/ZODB/interfaces.py	2009-12-31 19:54:00 UTC (rev 107467)
@@ -1217,6 +1217,20 @@
         """
 
 
+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.
+    """
+
+    def __setattr__(name, value):
+        """You cannot modify broken objects. This will raise a
+        ZODB.broken.BrokenModified exception.
+        """
+
+
 class BlobError(Exception):
     pass
 

Modified: ZODB/branches/hannosch-ibroken/src/ZODB/tests/testBroken.py
===================================================================
--- ZODB/branches/hannosch-ibroken/src/ZODB/tests/testBroken.py	2009-12-31 18:56:40 UTC (rev 107466)
+++ ZODB/branches/hannosch-ibroken/src/ZODB/tests/testBroken.py	2009-12-31 19:54:00 UTC (rev 107467)
@@ -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