API Reference for Enthought Tool Suite 3.2.0

Unpickles the state of an object saved using StatePickler.

Please note that unlike the standard Unpickler, no instances of any user class are created. The data for the state is obtained from the file or string, reference objects are setup to refer to the same state value and this state is returned in the form usually in the form of a dictionary. For example:

>>> class A:
...     def __init__(self):
...         self.attribute = 1
...
>>> a = A()
>>> p = StatePickler()
>>> s = p.dumps(a)
>>> up = StateUnpickler()
>>> state = up.loads_state(s)
>>> state.__class__.__name__
'State'
>>> state.attribute
1
>>> state.__metadata__
{'class_name': 'A',
 'has_instance': True,
 'id': 0,
 'initargs': (),
 'module': '__main__',
 'type': 'instance',
 'version': [(('A', '__main__'), -1)]}

Note that the state is actually a State instance and is navigable just like the original object. The details of the instance are stored in the __metadata__ attribute. This is highly convenient since it is possible for someone to view and modify the state very easily.

Method summary

Methods

© Copyright 2002-2009 Enthought, Inc.