Module storage
source code
storage.py: support for using Banana as if it were pickle
This includes functions for serializing to and from strings, instead
of a network socket. It also has support for serializing 'unsafe'
objects, specifically classes, modules, functions, and instances of
arbitrary classes. These are 'unsafe' because to recreate the object on
the deserializing end, we must be willing to execute code of the sender's
choosing (i.e. the constructor of whatever package.module.class names
they send us). It is unwise to do this unless you are willing to allow
your internal state to be compromised by the author of the serialized
data you're unpacking.
This functionality is isolated here because it is never used for data
coming over network connections.
|
|
getInstanceState(inst)
Utility function to default to 'normal' state rules in serialization. |
source code
|
|
|
|
setInstanceState(inst,
state)
Utility function to default to 'normal' state rules in
unserialization. |
source code
|
|
|
|
serialize(obj,
outstream=None,
root_class=<class foolscap.storage.StorageRootSlicer at 0x87284ac>,
banana=None)
Serialize an object graph into a sequence of bytes. |
source code
|
|
|
|
unserialize(str_or_instream,
banana=None,
root_class=<class 'foolscap.storage.StorageRootUnslicer'>)
Unserialize a sequence of bytes back into an object graph. |
source code
|
|
serialize(obj,
outstream=None,
root_class=<class foolscap.storage.StorageRootSlicer at 0x87284ac>,
banana=None)
| source code
|
Serialize an object graph into a sequence of bytes. Returns a Deferred
that fires with the sequence of bytes.
|
UnsafeSlicerTable
- Value:
{<type 'classobj'>: <class 'foolscap.storage.ClassSlicer'>,
<type 'instance'>: <class 'foolscap.storage.InstanceSlicer'>,
<type 'instancemethod'>: <class 'foolscap.storage.MethodSlicer'>,
<type 'module'>: <class 'foolscap.storage.ModuleSlicer'>,
<type 'function'>: <class 'foolscap.storage.FunctionSlicer'>}
|
|
UnsafeUnslicerRegistry
- Value:
{('class'): <class 'foolscap.storage.ClassUnslicer'>,
('function'): <class 'foolscap.storage.FunctionUnslicer'>,
('instance'): <class 'foolscap.storage.InstanceUnslicer'>,
('method'): <class 'foolscap.storage.MethodUnslicer'>,
('module'): <class 'foolscap.storage.ModuleUnslicer'>}
|
|