We have a Python binding to the Intersystems Cache OO database. It
provides an old style class in Python as an in memory instance of a
Cache class, and this is a intersystems.pythonbind.object type (= ipo).
The ipo class has three basic methods, namely, get, set, and
run_obj_method (which takes the Cache class method, as its first
argument, and the list of its arguments as the second argument)
e.g.
'John'>>CacheClass=ipo()
CacheClass.set('Name','John')
valName = CacheClass.get('Name')
print valName
I want to add functionality to ipo, so I have wrapped a new style class
(MyWrapper class, very basic) around it.
PythonCacheClass=MyWrapper(CacheClass)
Now, I want to make PythonCacheClass more pythonic, so I have a
dictionary of all the properties and values of each ipo. Eg
dicCacheProperties = {'Name':'John', 'Address':'The Strand'} etc
for key, val in dicCacheProperties.iteritems():
setattr(PythonCacheClass, key, val)
So now I have:
'John'>>>print PythonCacheClass.Name
My problem is this: how do I link the set and get methods of the ipo
class with the set and get methods in the wrapper class
PythonCacheClass?
So, I would like the following code:
to execute automatically>>PythonCacheClass.Name='Alexander'
CacheClass.set('Name','Alexander') etc
My thinking is that inside the PythonCacheClass, I can reference the
ipo class by self.get() - is this right? If so, how then do I set the
set attribute of the PythonCacheClass to automatically run
self.get().set('Name','Alexander')
I hope this is sufficiently clear. Am I tackling the problem the right
way?