Class
ZODB.broken.Broken

Broken object base class

Broken objects are placeholders for objects that can no longer be created because their class has gone away.

Broken objects don't really do much of anything, except hold their state. The Broken class is used as a base class for creating classes in leu of missing classes:

  >>> Atall = type('Atall', (Broken, ), {'__module__': 'not.there'})

The only thing the class can be used for is to create new objects:

  >>> Atall()
  <broken not.there.Atall instance>
  >>> Atall().__Broken_newargs__
  ()
  >>> Atall().__Broken_initargs__
  ()

  >>> Atall(1, 2).__Broken_newargs__
  (1, 2)
  >>> Atall(1, 2).__Broken_initargs__
  (1, 2)

  >>> a = Atall.__new__(Atall, 1, 2)
  >>> a
  <broken not.there.Atall instance>
  >>> a.__Broken_newargs__
  (1, 2)
  >>> a.__Broken_initargs__

You can't modify broken objects:

  >>> a.x = 1
  Traceback (most recent call last):
  ...
  BrokenModified: Can't change broken objects

But you can set their state:

  >>> a.__setstate__({'x': 1, })

You can pickle broken objects:

  >>> r = a.__reduce__()
  >>> len(r)
  3
  >>> r[0] is rebuild
  True
  >>> r[1]
  ('not.there', 'Atall', 1, 2)
  >>> r[2]
  {'x': 1}

  >>> import cPickle
  >>> a2 = cPickle.loads(cPickle.dumps(a, 1))
  >>> a2
  <broken not.there.Atall instance>
  >>> a2.__Broken_newargs__
  (1, 2)
  >>> a2.__Broken_initargs__
  >>> a2.__Broken_state__
  {'x': 1}

Cleanup:

  >>> broken_cache.clear()

Base classes

Implemented Interfaces

There are no implemented interfaces.

Attributes/Properties

There are no attributes in this class.

Methods

There are no methods in this class.

Known Subclasses