Salome HOME
correct previous integration (Porting to Python 2.6)
[modules/kernel.git] / src / KERNEL_PY / salome_genericobj.py
1 #  -*- coding: iso-8859-1 -*-
2
3 """
4  When imported this module adds to CORBA objref from GenericObj type
5  automatic management of reference count
6  The reference count is incremented when the local proxy is created (assignment of __omni_obj attribute)
7  and is decremented when the local proxy is deleted (call of __del__) 
8
9  The GenericObj class for proxy is modified by adding two methods : __del__ and __setattr__
10  The module must be imported before any other import of SALOME CORBA module
11 """
12 import omniORB
13 import SALOME
14
15 def mydel(self):
16     self.Destroy()
17     omniORB.CORBA.Object.__del__(self)
18
19 def mysetattr(self,attr,value):
20     self.__dict__[attr]=value
21     if attr == "__omni_obj":
22       self.Register()
23
24 SALOME._objref_GenericObj.__del__=mydel
25 SALOME._objref_GenericObj.__setattr__=mysetattr
26