Proposal to enhance MacPython preferences:
------------------------------------------
- Motivation : when embedding MacPython in MacCvs, I
realized the way MacPython is storing the preferences
in a solid Mac handle is a serious problem for MacCvs
in order to use several versions of MacPython, and
still being able to control the MacPython resources.
- The patch : it is not complete, it is *only* a
proposal for an under mechanism which stores
individually "Persistent" values, or values which have
the ability to be retained/loaded/saved accross
several MacPython sessions.
- The C side: example: defining a new persistent value
is as simple as:
static CPersistentInt version("version",
POPT_VERSION_CURRENT);
The value gets automatically linked to all the other
persistent values so they can be loaded and stored all
together. There are a set of pre-defined types of
persistent values (int, bool, string)
- The Python side : I have included a sample
testpersistent.py which illustrates how the script can
access, load, store the values.
Note : the C++ implementation is just for convenience
and RTTI is not used.
|