From: caremoli Date: Mon, 18 May 2009 17:11:32 +0000 (+0000) Subject: CCAR: add a python module for automatic management of genericobj X-Git-Tag: V5_1_2rc1~19 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8de2a5081b41e37c4b104771af7bc4c13f48e852;p=modules%2Fkernel.git CCAR: add a python module for automatic management of genericobj reference counting. The module is not active by default. It must be imported to activate the automatic reference counting --- diff --git a/src/KERNEL_PY/Makefile.am b/src/KERNEL_PY/Makefile.am index 869e2f913..6b2457c05 100755 --- a/src/KERNEL_PY/Makefile.am +++ b/src/KERNEL_PY/Makefile.am @@ -47,7 +47,8 @@ if CORBA_GEN omnipatch.py \ iparameters.py \ salome_version.py \ - salome_notebook.py + salome_notebook.py \ + salome_genericobj.py endif sharedpkgpython_PYTHON = kernel_shared_modules.py diff --git a/src/KERNEL_PY/salome_genericobj.py b/src/KERNEL_PY/salome_genericobj.py new file mode 100644 index 000000000..053f4ae1b --- /dev/null +++ b/src/KERNEL_PY/salome_genericobj.py @@ -0,0 +1,24 @@ +""" + When imported this module adds to CORBA objref from GenericObj type + automatic management of reference count + The reference count is incremented when the local proxy is created (assignment of __omni_obj attribute) + and is decremented when the local proxy is deleted (call of __del__) + + The GenericObj class for proxy is modified by adding two methods : __del__ and __setattr__ + The module must be imported before any other import of SALOME CORBA module +""" +import omniORB +import SALOME + +def mydel(self): + self.Destroy() + omniORB.CORBA.Object.__del__(self) + +def mysetattr(self,attr,value): + self.__dict__[attr]=value + if attr == "__omni_obj": + self.Register() + +SALOME._objref_GenericObj.__del__=mydel +SALOME._objref_GenericObj.__setattr__=mysetattr +