[Tutor] how-to override method in instance
Adam Groszer
adamg@mailbox.hu
Mon May 5 07:14:01 2003
Dear all,
I have an object (from omniORB), which has __del__ defined in it's base
class (CORBA.Object).
If I'm right I cannot override the class, from which the object is
instantiated.
But somehow I'd like to override the __del__ method of the object to do some
housekeeping when the object gets gc'd. Actually I'd like to call a method
on the server, then let the base __del__ do it's work.
I had something like this in my mind:
def janitor(self):
print 'janitor'
self.done() #call method on the server first
self.__super__del() #good-bye
...
obj.__super__del = obj.__del__
obj.__del__ = new.instancemethod(janitor, obj, obj.__class__)
...
Adam