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__)

Method __init__ Undocumented
Method __getstate__ Gets the state from the instance to be pickled
Method __setstate__ Sets the state to the instance when being unpickled
Method save No summary
Method set_filename Sets the name of the file which will be used to pickle the model
Class Method unpickle Loads an instance from a pickle file; if it fails for some reason, create a new instance.

Inherited from Model:

Method ensure_init Sets up the variables so the Model's getattr hook and proxy notification work properly.
Method disable_autonotify disable automatic notification to proxies based on __setattr__. All changes to the model must be followed by a call to notify_proxies() to allow the proxies to notice the change.
Method notify_proxies Notify proxies that an attribute value has changed.
Method register_proxy_for_attribute Attach a proxy to an attribute. The proxy will be notified of changes to that particular attribute (my means of Proxy.notify()).
Method unregister_proxy_for_attribute Detach a proxy from an attribute.
Method unregister_proxy Deattach a proxy completely from the model
Method flush_proxies Removes all proxies attached to Model
Method block_proxy Temporarily block a proxy from receiving any notification. See unblock_proxy()
Method unblock_proxy Re-enable notifications to a proxy
Method __setattr__ A special setattr hook that notifies the registered proxies that the model has changed. Work around it setting attributes directly to self.__dict__.
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()

Parametersfilenameoptional filename to pass in
def set_filename(self, filename):

Sets the name of the file which will be used to pickle the model

@classmethod
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.

API Documentation for Kiwi, generated by pydoctor at 2015-12-15 11:23:22.