Phoenix Logo

phoenix_title wx.lib.agw.persist.persistencemanager.PersistentObject

PersistentObject: ABC for anything persistent.

This is the base class for persistent object adapters. wxPython persistence framework is non-intrusive, i.e. can work with the classes which have no relationship to nor knowledge of it. To allow this, an intermediate persistence adapter is used: this is just a simple object which provides the methods used by PersistenceManager to save and restore the object properties and implements them using the concrete class methods.

You may derive your own classes from PersistentObject to implement persistence support for your common classes, see Defining Custom Persistent Windows in the __init__.py file.


class_hierarchy Class Hierarchy

Inheritance diagram for class PersistentObject:

method_summary Methods Summary

__init__ Default class constructor.
GetKind Returns the string uniquely identifying the objects supported by this adapter.
GetName Returns the string uniquely identifying the window we’re associated with
GetWindow Returns the actual associated window.
Restore Restores the corresponding window settings.
RestoreCtrlValue Restore the value saved by SaveCtrlValue, should be used only for
RestoreValue Restore the value saved by SaveValue.
Save Saves the corresponding window settings.
SaveCtrlValue Save the specified value using the given name, should be used only for
SaveValue Save the specified value using the given name.

api Class API



class PersistentObject(object)

PersistentObject: ABC for anything persistent.

This is the base class for persistent object adapters. wxPython persistence framework is non-intrusive, i.e. can work with the classes which have no relationship to nor knowledge of it. To allow this, an intermediate persistence adapter is used: this is just a simple object which provides the methods used by PersistenceManager to save and restore the object properties and implements them using the concrete class methods.

You may derive your own classes from PersistentObject to implement persistence support for your common classes, see Defining Custom Persistent Windows in the __init__.py file.


Methods



__init__(self, window, persistenceHandler=None)

Default class constructor.

Parameters:
  • window – an instance of wx.Window;
  • persistenceHandler – if not None, this should a custom handler derived from AbstractHandler.


GetKind(self)

Returns the string uniquely identifying the objects supported by this adapter.

Note

This method is called from SaveValue and RestoreValue and normally returns some short (but not too cryptic) strings, e.g. “Checkbox”.



GetName(self)

Returns the string uniquely identifying the window we’re associated with among all the other objects of the same type.

Note

This method is used together with GetKind to construct the unique full name of the object in e.g. a configuration file.



GetWindow(self)

Returns the actual associated window.



Restore(self)

Restores the corresponding window settings.

Note

This method shouldn’t be used directly as it doesn’t respect the global PersistenceManager.DisableRestoring() settings, use PersistenceManager methods with the same name instead.



RestoreCtrlValue(self, name)

Restore the value saved by SaveCtrlValue, should be used only for controls data value.

Parameters:name – the same name as was used by SaveCtrlValue.
Returns:True if the value was successfully read or False if it was not found or an error occurred.


RestoreValue(self, name)

Restore the value saved by SaveValue.

Parameters:name – the same name as was used by SaveValue.
Returns:True if the value was successfully read or False if it was not found or an error occurred.


Save(self)

Saves the corresponding window settings.

Note

This method shouldn’t be used directly as it doesn’t respect the global PersistenceManager.DisableSaving() settings, use PersistenceManager methods with the same name instead.



SaveCtrlValue(self, name, value)

Save the specified value using the given name, should be used only for controls data value.

Parameters:
  • name – the name of the value in the configuration file;
  • value – the value to save.
Returns:

True if the value was saved or False if an error occurred.



SaveValue(self, name, value)

Save the specified value using the given name.

Parameters:
  • name – the name of the value in the configuration file;
  • value – the value to save.
Returns:

True if the value was saved or False if an error occurred.