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 = "")
  _priority_sorter(a, b)

Variable Summary
list __alls__ = ['load', 'dump', 'loads', 'dumps', 'freeze_co...
dict _HANDLERS_ = {<type 'NoneType'>: <Cerealizer.NoneHandler...
Logger logger = <logging.Logger instance at 0x3bcbecac>
str VERSION = '0.5'
int _configurable = 1                                                                     
dict _HANDLERS = {'tuple\n': <Cerealizer.TupleHandler object ...

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 0x3bcdd10c>,
 <type 'int'>: <Cerealizer.IntHandler object at 0x3bcdd0cc>,
 <type 'list'>: <Cerealizer.ListHandler object at 0x3bcdd16c>,
 <type 'long'>: <Cerealizer.LongHandler object at 0x3bcdd0ec>,
 <type 'dict'>: <Cerealizer.DictHandler object at 0x3bcdd14c>,
 <type 'NoneType'>: <Cerealizer.NoneHandler object at 0x3bcdd04c>,
 <type 'str'>: <Cerealizer.StrHandler object at 0x3bcdd06c>,
 <type 'tuple'>: <Cerealizer.TupleHandler object at 0x3bcdd1ac>,
...                                                                    

logger

Type:
Logger
Value:
<logging.Logger instance at 0x3bcbecac>                                

VERSION

Type:
str
Value:
'0.5'                                                                  

_configurable

Type:
int
Value:
1                                                                     

_HANDLERS

Type:
dict
Value:
{'dict\n': <Cerealizer.DictHandler object at 0x3bcdd14c>,
 'frozenset\n': <Cerealizer.FrozensetHandler object at 0x3bcdd1cc>,
 'list\n': <Cerealizer.ListHandler object at 0x3bcdd16c>,
 'set\n': <Cerealizer.SetHandler object at 0x3bcdd18c>,
 'tuple\n': <Cerealizer.TupleHandler object at 0x3bcdd1ac>}            

Generated by Epydoc 2.1 on Thu Aug 31 00:17:50 2006 http://epydoc.sf.net