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 |
Function | save | Saves the instance to a pickle filename. If no filename argument is |
Function | set_filename | Sets the name of the file which will be used to pickle the |
Function | unpickle | Loads an instance from a pickle file; if it fails for some reason, |
Gets the state from the instance to be pickled
Sets the state to the instance when being unpickled
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()
Sets the name of the file which will be used to pickle the model
Loads an instance from a pickle file; if it fails for some reason, create a new instance.
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.