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