]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Get access of variable in the context dict of PyScriptNode instance.
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 30 Jul 2019 12:01:19 +0000 (14:01 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 30 Jul 2019 12:01:19 +0000 (14:01 +0200)
idl/SALOME_PyNode.idl
src/Container/SALOME_PyNode.py

index e3dfd3c847f159092f36fbf8fad3e070f20a0542..6c8af42415530227ea50aef0cac27cc32d1bb453 100644 (file)
@@ -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);
   } ;
 
 };
index be34f21fc1076cc927c1e4594eda20082ea4cdbe..48a839e8c8c31e0627aee67aa6cb84695d6946a3 100644 (file)
@@ -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