Commit 4e826256 authored by Jim Fulton's avatar Jim Fulton

Merged the hannosch-ibroken branch which provides an interface for

broken objects.
parent f0dc0114
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
3.10.0a1 (2009-12-??) 3.10.0a1 (2009-12-??)
===================== =====================
New Features
------------
- Broken objects now provide the IBroken interface.
Bugs Fixed Bugs Fixed
---------- ----------
......
...@@ -19,6 +19,10 @@ $Id$ ...@@ -19,6 +19,10 @@ $Id$
import sys import sys
import persistent import persistent
import zope.interface
import ZODB.interfaces
broken_cache = {} broken_cache = {}
class Broken(object): class Broken(object):
...@@ -92,6 +96,8 @@ class Broken(object): ...@@ -92,6 +96,8 @@ class Broken(object):
>>> broken_cache.clear() >>> broken_cache.clear()
""" """
zope.interface.implements(ZODB.interfaces.IBroken)
__Broken_state__ = __Broken_initargs__ = None __Broken_state__ = __Broken_initargs__ = None
__name__ = 'broken object' __name__ = 'broken object'
......
...@@ -1217,6 +1217,32 @@ class IBlobStorageRestoreable(IBlobStorage, IStorageRestoreable): ...@@ -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): class BlobError(Exception):
pass pass
......
...@@ -71,6 +71,12 @@ def test_integration(): ...@@ -71,6 +71,12 @@ def test_integration():
>>> a3.__Broken_state__ >>> a3.__Broken_state__
{'x': 1} {'x': 1}
Broken objects provide an interface:
>>> from ZODB.interfaces import IBroken
>>> IBroken.providedBy(a3)
True
Let's clean up: Let's clean up:
>>> db.close() >>> 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