Cerealizer

Module Cerealizer |
[show private | hide private]
[frames | no frames]

## Module Cerealizer

Classes
`BoolHandler` |
`ComplexHandler` |
`DictHandler` |
`Dumper` |
`FloatHandler` |
`FrozensetHandler` |
`Handler` | Handler
`InitArgsObjHandler` | InitArgsObjHandler
`IntHandler` |
`ListHandler` |
`LongHandler` |
`NewArgsObjHandler` | NewArgsObjHandler
`NoneHandler` |
`ObjHandler` | ObjHandler
`RefHandler` |
`SetHandler` |
`SlotedObjHandler` | SlotedObjHandler
`StrHandler` |
`TupleHandler` |
`UnicodeHandler` |

Exceptions
`NonCerealizableObjectError` |
`NotCerealizerFileError` |

Function Summary
| ``dump`(obj, file, protocol)` dump(obj, file, protocol = 0)
| ``dump_class_of_module`(*modules)` dump_class_of_module(*modules)
| ``dumps`(obj, protocol)` dumps(obj, protocol = 0) -> str
| ``freeze_configuration`()` freeze_configuration()
| ``load`(file)` load(file) -> obj
| ``loads`(string)` loads(file) -> obj
| ``register`(Class, handler, classname)` register(Class, handler = None, classname = "")
| ``register_alias`(Class, alias)` register_alias(Class, alias) Registers ALIAS as an alias classname for CLASS.
| ``register_class`(Class, handler, classname)` register(Class, handler = None, classname = "")

Variable Summary
`list` | `__alls__` = `['load', 'dump', 'loads', 'dumps', 'freeze_co...`
`dict` | `_HANDLERS_` = `{<type 'NoneType'>: <Cerealizer.NoneHandler...`
`Logger` | `logger` = `<logging.Logger instance at 0x4141cc0c>`
`str` | `VERSION` = `'0.5'`

Function Details

### dump(obj, file, protocol=0) dump(obj, file, protocol = 0) Serializes object OBJ in FILE. PROTOCOL is unused, it exists only for compatibility with Pickle.

### dump_class_of_module(*modules) dump_class_of_module(*modules) Utility function; for each classes found in the given module, print the needed call to register.

### dumps(obj, protocol=0) dumps(obj, protocol = 0) -> str Serializes object OBJ and returns the serialized string. PROTOCOL is unused, it exists only for compatibility with Pickle.

### freeze_configuration() freeze_configuration() Ends Cerealizer configuration. When freeze_configuration() is called, it is no longer possible to register classes, using register(). Calling freeze_configuration() is not mandatory, but it may enforce security, by forbidding unexpected calls to register().

### load(file) load(file) -> obj De-serializes an object from FILE.

### loads(string) loads(file) -> obj De-serializes an object from STRING.

### register(Class, handler=None, classname='') register(Class, handler = None, classname = "") Registers CLASS as a serializable and secure class. By calling register, YOU HAVE TO ASSUME THAT THE FOLLOWING METHODS ARE SECURE: CLASS.__new__ CLASS.__del__ CLASS.__getstate__ CLASS.__setstate__ CLASS.__getinitargs__ CLASS.__init__ (only if CLASS.__getinitargs__ exists) HANDLER is the Cerealizer Handler object that handles serialization and deserialization for Class. If not given, Cerealizer create an instance of ObjHandler, which is suitable for old-style and new_style Python class, and also C-defined types (although if it has some C-side data, you may have to write a custom Handler or a __getstate__ and __setstate__ pair). CLASSNAME is the classname used in Cerealizer files. It defaults to the full classname (module.class) but you may choose something shorter -- as long as there is no risk of name clash.

### register_alias(Class, alias)
    register_alias(Class, alias)

    Registers ALIAS as an alias classname for CLASS.
    Usefull for keeping backward compatibility in files: e.g. if you have renamed OldClass to
    NewClass, just do:

        cerealizer.register_alias(NewClass, "OldClass")

    and you'll be able to open old files containing OldClass serialized.

### register_class(Class, handler=None, classname='') register(Class, handler = None, classname = "") Registers CLASS as a serializable and secure class. By calling register, YOU HAVE TO ASSUME THAT THE FOLLOWING METHODS ARE SECURE: CLASS.__new__ CLASS.__del__ CLASS.__getstate__ CLASS.__setstate__ CLASS.__getinitargs__ CLASS.__init__ (only if CLASS.__getinitargs__ exists) HANDLER is the Cerealizer Handler object that handles serialization and deserialization for Class. If not given, Cerealizer create an instance of ObjHandler, which is suitable for old-style and new_style Python class, and also C-defined types (although if it has some C-side data, you may have to write a custom Handler or a __getstate__ and __setstate__ pair). CLASSNAME is the classname used in Cerealizer files. It defaults to the full classname (module.class) but you may choose something shorter -- as long as there is no risk of name clash.

Variable Details

    ### __alls__ Type: `list` Value:
        ['load', 'dump', 'loads', 'dumps', 'freeze_configuration', 'register']

    ### _HANDLERS_ Type: `dict` Value:
        {<type 'float'>: <Cerealizer.FloatHandler object at 0x414301ac>,
         <type 'int'>: <Cerealizer.IntHandler object at 0x4143016c>,
         <type 'list'>: <Cerealizer.ListHandler object at 0x4143020c>,
         <type 'long'>: <Cerealizer.LongHandler object at 0x4143018c>,
         <type 'dict'>: <Cerealizer.DictHandler object at 0x414301ec>,
         <type 'NoneType'>: <Cerealizer.NoneHandler object at 0x414300ec>,
         <type 'str'>: <Cerealizer.StrHandler object at 0x4143010c>,
         <type 'tuple'>: <Cerealizer.TupleHandler object at 0x4143024c>,
        ...

    ### logger Type: `Logger` Value:
        <logging.Logger instance at 0x4141cc0c>

    ### VERSION Type: `str` Value:
        '0.5'

Generated by Epydoc 2.1 on Thu Nov 23 23:40:43 2006 | http://epydoc.sf.net