AGW Logo

agw_title 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.

hierarchy Inheritance Diagram

Inheritance diagram for: PersistentObject

Inheritance diagram of PersistentObject


method_summary Methods Summary

__init__Default class constructor.
GetKindReturns the string uniquely identifying the objects supported by this adapter.
GetNameReturns the string uniquely identifying the window we’re associated with among all the other objects of the same type.
GetWindowReturns the actual associated window.
RestoreRestores the corresponding window settings.
RestoreCtrlValueRestore the value saved by SaveCtrlValue, should be used only for
RestoreValueRestore the value saved by SaveValue.
SaveSaves the corresponding window settings.
SaveCtrlValueSave the specified value using the given name, should be used only for controls data value.
SaveValueSave the specified value using the given name.

API Class API

class PersistentObject(object)[source]

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.



__init__(window, persistenceHandler=None)[source]

Default class constructor.

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


GetKind()[source]

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()[source]

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()[source]

Returns the actual associated window.



Restore()[source]

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(name)[source]

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(name)[source]

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()[source]

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(name, value)[source]

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(name, value)[source]

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.

Tree

Table Of Contents

Previous topic

PersistenceManager

Next topic

SVN Revision 69550 For persistencemanager