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