From: Anthony Geay Date: Tue, 30 Jul 2019 12:01:19 +0000 (+0200) Subject: Get access of variable in the context dict of PyScriptNode instance. X-Git-Tag: V9_4_0a1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=04e2e3b26a5125a4484c45ae9fc9811eb90c7601;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 e3dfd3c84..6c8af4241 100644 --- a/idl/SALOME_PyNode.idl +++ b/idl/SALOME_PyNode.idl @@ -84,6 +84,10 @@ module Engines pickledArgs getValueOfVarInContext(in string varName) raises (SALOME::SALOME_Exception); + + void assignVarInContext(in string varName, in pickledArgs value) raises (SALOME::SALOME_Exception); + + pickledArgs callMethodOnVarInContext(in string varName, in string methodName, in pickledArgs args) raises (SALOME::SALOME_Exception); } ; }; diff --git a/src/Container/SALOME_PyNode.py b/src/Container/SALOME_PyNode.py index be34f21fc..48a839e8c 100644 --- a/src/Container/SALOME_PyNode.py +++ b/src/Container/SALOME_PyNode.py @@ -150,3 +150,22 @@ 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" %self.nodeName,0)) + pass + + def assignVarInContext(self, varName, value): + try: + self.context[varName][0] = pickle.loads(value) + 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)) + pass + + def callMethodOnVarInContext(self, varName, methodName, args): + try: + return pickle.dumps( getattr(self.context[varName][0],methodName)(*pickle.loads(args)),-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)) + pass