Salome HOME
0023299: [CEA] Finalize multi-study removal
[modules/kernel.git] / src / Container / SALOME_PyNode.py
index 04ce26b7ab26ce79d5f76325730808610df146ba..2feb5d4c9ceb0ddd0efbd4c131d64df39a767c1c 100644 (file)
@@ -1,6 +1,6 @@
 #! /usr/bin/env python
 #  -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -64,6 +64,18 @@ class PyNode_i (Engines__POA.PyNode,Generic):
     self.context["my_container"] = self.my_container
     exec ccode in self.context
 
+  def defineNewCustomVar(self,varName,valueOfVar):
+    self.context[varName] = cPickle.loads(valueOfVar)
+    pass
+
+  def executeAnotherPieceOfCode(self,code):
+    """Called for initialization of container lodging self."""
+    try:
+      ccode=compile(code,self.nodeName,'exec')
+      exec ccode in self.context
+    except:
+      raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"","PyScriptNode (%s) : code to be executed \"%s\"" %(self.nodeName,code),0))
+
   def execute(self,funcName,argsin):
     """Execute the function funcName found in local context with pickled args (argsin)"""
     try:
@@ -90,6 +102,25 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic):
     self.context={}
     self.context["my_container"] = self.my_container
 
+  def defineNewCustomVar(self,varName,valueOfVar):
+    self.context[varName] = cPickle.loads(valueOfVar)
+    pass
+
+  def executeAnotherPieceOfCode(self,code):
+    """Called for initialization of container lodging self."""
+    try:
+      ccode=compile(code,self.nodeName,'exec')
+      exec ccode in self.context
+    except:
+      raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"","PyScriptNode (%s) : code to be executed \"%s\"" %(self.nodeName,code),0))
+
+  def assignNewCompiledCode(self,codeStr):
+    try:
+      self.code=codeStr
+      self.ccode=compile(codeStr,self.nodeName,'exec')
+    except:
+      raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"","PyScriptNode.assignNewCompiledCode (%s) : code to be executed \"%s\"" %(self.nodeName,codeStr),0))
+
   def execute(self,outargsname,argsin):
     """Execute the script stored in attribute ccode with pickled args (argsin)"""
     try: