Class k.m.PickledModel(Model):

Part of kiwi.model
PickledModel is a model that is able to save itself into a pickle using save(). This has all the limitations of a pickle: its instance variables must be picklable, or pickle.dump() will raise exceptions. You can prefix variables with an underscore to make them non-persistent (and you can restore them accordingly by overriding __setstate__, but don't forget to call PickledModel.__setstate__)
Function__init__Undocumented
Function__getstate__
Gets the state from the instance to be pickled
Function__setstate__
Sets the state to the instance when being unpickled
Functionsave
Saves the instance to a pickle filename. If no filename argument is
Functionset_filename
Sets the name of the file which will be used to pickle the
Functionunpickle
Loads an instance from a pickle file; if it fails for some reason,
def __init__(self):
Undocumented
def __getstate__(self):
Gets the state from the instance to be pickled
def __setstate__(self, dict):
Sets the state to the instance when being unpickled
def save(self, filename=None):
Saves the instance to a pickle filename. If no filename argument is provided, will try to use the internal _filename attribute that is set using set_filename()
def set_filename(self, filename):
Sets the name of the file which will be used to pickle the model
def unpickle(cls, filename=None):
Loads an instance from a pickle file; if it fails for some reason, create a new instance.
  • filename: the file from which the pickle should be loaded. If file is not provided, the name of the class suffixed by ".pickle" is used (i.e. "FooClass.pickle" for the class FooClass).
If the pickle file is damaged, it will be saved with the extension ".err"; if a file with that name also exists, it will use ".err.1" and so on. This is to avoid the damaged file being clobbered by an instance calling save() unsuspectingly.