From: Anthony Geay Date: Tue, 30 Jul 2019 08:31:08 +0000 (+0200) Subject: Get access of variable in the context dict of PyScriptNode instance. X-Git-Tag: V9_4_0a1~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b5dda8624480ec1f9717ecbcb0fbab008faa0573;p=modules%2Fkernel.git Get access of variable in the context dict of PyScriptNode instance. --- diff --git a/idl/SALOME_PyNode.idl b/idl/SALOME_PyNode.idl index 8a5d37562..e3dfd3c84 100644 --- a/idl/SALOME_PyNode.idl +++ b/idl/SALOME_PyNode.idl @@ -82,6 +82,8 @@ module Engines */ pickledArgs execute(in listofstring outargsname, in pickledArgs inargs) raises (SALOME::SALOME_Exception); + + pickledArgs getValueOfVarInContext(in string varName) raises (SALOME::SALOME_Exception); } ; }; diff --git a/src/Container/SALOME_PyNode.py b/src/Container/SALOME_PyNode.py index dc6cb552a..be34f21fc 100644 --- a/src/Container/SALOME_PyNode.py +++ b/src/Container/SALOME_PyNode.py @@ -37,9 +37,11 @@ class Generic(SALOME__POA.GenericObj): self.cnt=1 def Register(self): + print("Register called : %d"%self.cnt) self.cnt+=1 def UnRegister(self): + print("UnRegister called : %d"%self.cnt) self.cnt-=1 if self.cnt <= 0: oid=self.poa.servant_to_id(self) @@ -49,6 +51,9 @@ class Generic(SALOME__POA.GenericObj): print("WARNING SALOME::GenericObj::Destroy() function is obsolete! Use UnRegister() instead.") self.UnRegister() + def __del__(self): + print("Destuctor called") + class PyNode_i (Engines__POA.PyNode,Generic): """The implementation of the PyNode CORBA IDL""" def __init__(self, nodeName,code,poa,my_container): @@ -137,3 +142,11 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic): exc_typ,exc_val,exc_fr=sys.exc_info() l=traceback.format_exception(exc_typ,exc_val,exc_fr) raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyScriptNode: %s, outargsname: %s" % (self.nodeName,outargsname),0)) + + def getValueOfVarInContext(self,varName): + try: + return pickle.dumps(self.context[varName],-1) + except: + exc_typ,exc_val,exc_fr=sys.exc_info() + l=traceback.format_exception(exc_typ,exc_val,exc_fr) + raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyScriptNode: %s" %self.nodeName,0))