Commit af947463 authored by Jim Fulton's avatar Jim Fulton

Merged the hannosch-ibroken branch which provides an interface for

broken objects.
parent 05ca590e
......@@ -5,6 +5,11 @@
3.10.0a1 (2009-12-??)
=====================
New Features
------------
- Broken objects now provide the IBroken interface.
Bugs Fixed
----------
......
......@@ -19,6 +19,10 @@ $Id$
import sys
import persistent
import zope.interface
import ZODB.interfaces
broken_cache = {}
class Broken(object):
......@@ -92,6 +96,8 @@ class Broken(object):
>>> broken_cache.clear()
"""
zope.interface.implements(ZODB.interfaces.IBroken)
__Broken_state__ = __Broken_initargs__ = None
__name__ = 'broken object'
......
......@@ -1217,6 +1217,32 @@ class IBlobStorageRestoreable(IBlobStorage, IStorageRestoreable):
"""
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
......
......@@ -71,6 +71,12 @@ def test_integration():
>>> 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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment