Salome HOME
Some factorization in python nodes concerning remote load part.
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 13 Aug 2014 15:19:23 +0000 (17:19 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 13 Aug 2014 15:19:23 +0000 (17:19 +0200)
src/engine/Node.hxx
src/runtime/PythonNode.cxx
src/runtime/PythonNode.hxx

index 4101ec559b6f82b31cc40d05e22c5e848c3ff527..e7c865b6cadee3e0475c5072f5639c278f7949ed 100644 (file)
@@ -158,7 +158,7 @@ namespace YACS
       virtual void setProperty(const std::string& name,const std::string& value);
       virtual std::string getProperty(const std::string& name);
       std::map<std::string,std::string> getProperties() ;
-      std::map<std::string,std::string> getPropertyMap(){return _propertyMap;} ;
+      std::map<std::string,std::string> getPropertyMap() { return _propertyMap; }
       virtual void setProperties(std::map<std::string,std::string> properties);
       virtual Node *getChildByName(const std::string& name) const throw(Exception) = 0;
       virtual Proc *getProc();
@@ -168,17 +168,17 @@ namespace YACS
       int getNumId();
       virtual void sendEvent(const std::string& event);
       static std::map<int,Node *> idMap;
-      virtual std::string typeName() {return "YACS__ENGINE__Node";}
-      virtual std::string getErrorDetails(){return _errorDetails;};
-      virtual void setErrorDetails(const std::string& error){_errorDetails=error;};
+      virtual std::string typeName() { return "YACS__ENGINE__Node"; }
+      virtual std::string getErrorDetails() const { return _errorDetails; }
+      virtual void setErrorDetails(const std::string& error) { _errorDetails=error; }
       virtual void modified();
-      virtual int isModified(){return _modified;}
+      virtual int isModified() { return _modified; }
       virtual int isValid();
       virtual void edUpdateState();
       virtual std::string getErrorReport();
       virtual std::string getContainerLog();
       virtual void ensureLoading();
-      virtual void getCoupledNodes(std::set<Task*>& coupledNodes){};
+      virtual void getCoupledNodes(std::set<Task*>& coupledNodes) { }
       virtual void cleanNodes();
     protected:
       virtual void exForwardFailed();
index db29917d389bc2d27d8e7c821f034992bd1de6c9..72df372bfd25ab52161f5a1aa3f94d0422448265 100644 (file)
@@ -51,6 +51,171 @@ using namespace std;
 const char PythonNode::IMPL_NAME[]="Python";
 const char PythonNode::KIND[]="Python";
 
+const char PythonNode::SCRIPT_FOR_SERIALIZATION[]="import cPickle\n"
+    "def pickleForDistPyth2009(kws):\n"
+    "  return cPickle.dumps(((),kws),-1)\n"
+    "\n"
+    "def unPickleForDistPyth2009(st):\n"
+    "  args=cPickle.loads(st)\n"
+    "  return args\n";
+
+const char PyFuncNode::SCRIPT_FOR_SERIALIZATION[]="import cPickle\n"
+    "def pickleForDistPyth2009(*args,**kws):\n"
+    "  return cPickle.dumps((args,kws),-1)\n"
+    "\n"
+    "def unPickleForDistPyth2009(st):\n"
+    "  args=cPickle.loads(st)\n"
+    "  return args\n";
+
+PythonEntry::PythonEntry():_context(0),_pyfuncSer(0),_pyfuncUnser(0)
+{
+}
+
+PythonEntry::~PythonEntry()
+{
+  AutoGIL agil;
+  DEBTRACE( "_context refcnt: " << _context->ob_refcnt );
+  Py_XDECREF(_pyfuncUnser);
+  Py_XDECREF(_pyfuncSer);
+  Py_XDECREF(_context);
+}
+
+void PythonEntry::commonRemoteLoad(InlineNode *reqNode)
+{
+  DEBTRACE( "---------------PythonEntry::CommonRemoteLoad function---------------" );
+  Container *container(reqNode->getContainer());
+  bool isContAlreadyStarted(false);
+  if(container)
+    {
+      isContAlreadyStarted=container->isAlreadyStarted(reqNode);
+      if(!isContAlreadyStarted)
+        {
+          try
+          {
+              container->start(reqNode);
+          }
+          catch(Exception& e)
+          {
+              reqNode->setErrorDetails(e.what());
+              throw e;
+          }
+        }
+    }
+  else
+    {
+      std::string what("PythonEntry::CommonRemoteLoad : a load operation requested on \"");
+      what+=reqNode->getName(); what+="\" with no container specified.";
+      reqNode->setErrorDetails(what);
+      throw Exception(what);
+    }
+  Engines::Container_var objContainer=Engines::Container::_nil();
+  if(!container)
+    throw Exception("No container specified !");
+  SalomeContainer *containerCast0(dynamic_cast<SalomeContainer *>(container));
+  SalomeHPContainer *containerCast1(dynamic_cast<SalomeHPContainer *>(container));
+  if(containerCast0)
+    objContainer=containerCast0->getContainerPtr(reqNode);
+  else if(containerCast1)
+    {
+      YACS::BASES::AutoCppPtr<SalomeContainerTmpForHP> tmpCont(SalomeContainerTmpForHP::BuildFrom(containerCast1,reqNode));
+      objContainer=tmpCont->getContainerPtr(reqNode);
+    }
+  else
+    throw Exception("Unrecognized type of container ! Salome one is expected for PythonNode/PyFuncNode !");
+  if(CORBA::is_nil(objContainer))
+    throw Exception("Container corba pointer is NULL for PythonNode !");
+  bool isInitializeRequested(false);
+  try
+  {
+      if(containerCast0)
+        {
+          createRemoteAdaptedPyInterpretor(objContainer);
+        }
+      else
+        {
+          Engines::PyNodeBase_var dftPyScript(retrieveDftRemotePyInterpretorIfAny(objContainer));
+          if(CORBA::is_nil(dftPyScript))
+            {
+              isInitializeRequested=true;
+              createRemoteAdaptedPyInterpretor(objContainer);
+            }
+          else
+            assignRemotePyInterpretor(dftPyScript);
+        }
+  }
+  catch( const SALOME::SALOME_Exception& ex )
+  {
+      std::string msg="Exception on remote python node creation ";
+      msg += '\n';
+      msg += ex.details.text.in();
+      reqNode->setErrorDetails(msg);
+      throw Exception(msg);
+  }
+  Engines::PyNodeBase_var pynode(getRemoteInterpreterHandle());
+  if(CORBA::is_nil(pynode))
+    throw Exception("In PythonNode the ref in NULL ! ");
+  ///
+  {
+      AutoGIL agil;
+      const char *picklizeScript(getSerializationScript());
+      PyObject *res=PyRun_String(picklizeScript,Py_file_input,_context,_context);
+      if(res == NULL)
+        {
+          std::string errorDetails;
+          PyObject* new_stderr = newPyStdOut(errorDetails);
+          reqNode->setErrorDetails(errorDetails);
+          PySys_SetObject((char*)"stderr", new_stderr);
+          PyErr_Print();
+          PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+          Py_DECREF(new_stderr);
+          throw Exception("Error during load");
+        }
+      Py_DECREF(res);
+      _pyfuncSer=PyDict_GetItemString(_context,"pickleForDistPyth2009");
+      _pyfuncUnser=PyDict_GetItemString(_context,"unPickleForDistPyth2009");
+      if(_pyfuncSer == NULL)
+        {
+          std::string errorDetails;
+          PyObject *new_stderr(newPyStdOut(errorDetails));
+          reqNode->setErrorDetails(errorDetails);
+          PySys_SetObject((char*)"stderr", new_stderr);
+          PyErr_Print();
+          PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+          Py_DECREF(new_stderr);
+          throw Exception("Error during load");
+        }
+      if(_pyfuncUnser == NULL)
+        {
+          std::string errorDetails;
+          PyObject *new_stderr(newPyStdOut(errorDetails));
+          reqNode->setErrorDetails(errorDetails);
+          PySys_SetObject((char*)"stderr", new_stderr);
+          PyErr_Print();
+          PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+          Py_DECREF(new_stderr);
+          throw Exception("Error during load");
+        }
+      if(isInitializeRequested)
+        {//This one is called only once at initialization in the container if an init-script is specified.
+          try
+          {
+              std::string zeInitScriptKey(container->getProperty(HomogeneousPoolContainer::INITIALIZE_SCRIPT_KEY));
+              if(!zeInitScriptKey.empty())
+                pynode->executeAnotherPieceOfCode(zeInitScriptKey.c_str());
+          }
+          catch( const SALOME::SALOME_Exception& ex )
+          {
+              std::string msg="Exception on PythonNode::loadRemote python invocation of initializisation py script !";
+              msg += '\n';
+              msg += ex.details.text.in();
+              reqNode->setErrorDetails(msg);
+              throw Exception(msg);
+          }
+        }
+      DEBTRACE( "---------------End PyNode::loadRemote function---------------" );
+  }
+}
+
 PythonNode::PythonNode(const PythonNode& other, ComposedNode *father):InlineNode(other,father)
 {
   _implementation=IMPL_NAME;
@@ -85,9 +250,10 @@ PythonNode::PythonNode(const std::string& name):InlineNode(name)
 
 PythonNode::~PythonNode()
 {
-  AutoGIL agil;
-  DEBTRACE( "_context refcnt: " << _context->ob_refcnt );
-  Py_DECREF(_context);
+  if(!CORBA::is_nil(_pynode))
+    {
+      _pynode->UnRegister();
+    }
 }
 
 void PythonNode::checkBasicConsistency() const throw(YACS::Exception)
@@ -130,144 +296,7 @@ void PythonNode::loadLocal()
 
 void PythonNode::loadRemote()
 {
-  DEBTRACE( "---------------PyNode::loadRemote function---------------" );
-  bool isContAlreadyStarted(false);
-  if(_container)
-    {
-      isContAlreadyStarted=_container->isAlreadyStarted(this);
-      if(!isContAlreadyStarted)
-        {
-          try
-            {
-              _container->start(this);
-            }
-          catch(Exception& e)
-            {
-              _errorDetails=e.what();
-              throw e;
-            }
-        }
-    }
-  else
-    {
-      std::string what("PyNode::loadRemote : a load operation requested on \"");
-      what+=_name; what+="\" with no container specified.";
-      _errorDetails=what;
-      throw Exception(what);
-    }
-
-
-  Engines::Container_var objContainer=Engines::Container::_nil();
-  if(!_container)
-    throw Exception("No container specified !");
-  SalomeContainer *containerCast0(dynamic_cast<SalomeContainer *>(_container));
-  SalomeHPContainer *containerCast1(dynamic_cast<SalomeHPContainer *>(_container));
-  if(containerCast0)
-    objContainer=containerCast0->getContainerPtr(this);
-  else if(containerCast1)
-    {
-      YACS::BASES::AutoCppPtr<SalomeContainerTmpForHP> tmpCont(SalomeContainerTmpForHP::BuildFrom(containerCast1,this));
-      objContainer=tmpCont->getContainerPtr(this);
-    }
-  else
-    throw Exception("Unrecognized type of container ! Salome one is expected for PythonNode !");
-  if(CORBA::is_nil(objContainer))
-    throw Exception("Container corba pointer is NULL for PythonNode !");
-  bool isInitializeRequested(false);
-  try
-    {
-      if(containerCast0)
-        {
-          _pynode = objContainer->createPyScriptNode(getName().c_str(),getScript().c_str());
-        }
-      else
-        {
-          Engines::PyScriptNode_var dftPyScript(objContainer->getDefaultPyScriptNode());
-          if(CORBA::is_nil(dftPyScript))
-            {
-              isInitializeRequested=true;
-              _pynode = objContainer->createPyScriptNode(getName().c_str(),getScript().c_str());
-            }
-          else
-            _pynode = dftPyScript;
-        }
-    }
-  catch( const SALOME::SALOME_Exception& ex )
-    {
-      std::string msg="Exception on remote python node creation ";
-      msg += '\n';
-      msg += ex.details.text.in();
-      _errorDetails=msg;
-      throw Exception(msg);
-    }
-
-  if(CORBA::is_nil(_pynode))
-    throw Exception("In PythonNode the ref in NULL ! ");
-
-  ///
-  {
-    AutoGIL agil;
-    const char picklizeScript[]="import cPickle\n"
-        "def pickleForDistPyth2009(kws):\n"
-        "  return cPickle.dumps(((),kws),-1)\n"
-        "\n"
-        "def unPickleForDistPyth2009(st):\n"
-        "  args=cPickle.loads(st)\n"
-        "  return args\n";
-    PyObject *res=PyRun_String(picklizeScript,Py_file_input,_context,_context);
-    if(res == NULL)
-      {
-        _errorDetails="";
-        PyObject* new_stderr = newPyStdOut(_errorDetails);
-        PySys_SetObject((char*)"stderr", new_stderr);
-        PyErr_Print();
-        PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
-        Py_DECREF(new_stderr);
-        throw Exception("Error during load");
-      }
-    Py_DECREF(res);
-
-    _pyfuncSer=PyDict_GetItemString(_context,"pickleForDistPyth2009");
-    _pyfuncUnser=PyDict_GetItemString(_context,"unPickleForDistPyth2009");
-    if(_pyfuncSer == NULL)
-      {
-        _errorDetails="";
-        PyObject* new_stderr = newPyStdOut(_errorDetails);
-        PySys_SetObject((char*)"stderr", new_stderr);
-        PyErr_Print();
-        PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
-        Py_DECREF(new_stderr);
-        throw Exception("Error during load");
-      }
-    if(_pyfuncUnser == NULL)
-      {
-        _errorDetails="";
-        PyObject* new_stderr = newPyStdOut(_errorDetails);
-        PySys_SetObject((char*)"stderr", new_stderr);
-        PyErr_Print();
-        PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
-        Py_DECREF(new_stderr);
-        throw Exception("Error during load");
-      }
-    if(isInitializeRequested)
-      {//This one is called only once at initialization in the container if an init-script is specified.
-        try
-        {
-            std::string zeInitScriptKey(_container->getProperty(HomogeneousPoolContainer::INITIALIZE_SCRIPT_KEY));
-            if(!zeInitScriptKey.empty())
-              _pynode->executeAnotherPieceOfCode(zeInitScriptKey.c_str());
-        }
-        catch( const SALOME::SALOME_Exception& ex )
-        {
-            std::string msg="Exception on PythonNode::loadRemote python invocation of initializisation py script !";
-            msg += '\n';
-            msg += ex.details.text.in();
-            _errorDetails=msg;
-            throw Exception(msg);
-        }
-      }
-    DEBTRACE( "---------------End PyNode::loadRemote function---------------" );
-  }
+  commonRemoteLoad(this);
 }
 
 void PythonNode::execute()
@@ -564,6 +593,33 @@ Node *PythonNode::simpleClone(ComposedNode *father, bool editionOnly) const
   return new PythonNode(*this,father);
 }
 
+void PythonNode::createRemoteAdaptedPyInterpretor(Engines::Container_ptr objContainer)
+{
+  if(!CORBA::is_nil(_pynode))
+    _pynode->UnRegister();
+  _pynode=objContainer->createPyScriptNode(getName().c_str(),getScript().c_str());
+}
+
+Engines::PyNodeBase_var PythonNode::retrieveDftRemotePyInterpretorIfAny(Engines::Container_ptr objContainer) const
+{
+  Engines::PyScriptNode_var ret(objContainer->getDefaultPyScriptNode());
+  if(!CORBA::is_nil(ret))
+    {
+      ret->Register();
+    }
+  return Engines::PyNodeBase::_narrow(ret);
+}
+
+void PythonNode::assignRemotePyInterpretor(Engines::PyNodeBase_var remoteInterp)
+{
+  _pynode=Engines::PyScriptNode::_narrow(remoteInterp);
+}
+
+Engines::PyNodeBase_var PythonNode::getRemoteInterpreterHandle()
+{
+  return Engines::PyNodeBase::_narrow(_pynode);
+}
+
 //! Create a new node of same type with a given name
 PythonNode* PythonNode::cloneNode(const std::string& name)
 {
@@ -626,13 +682,6 @@ PyFuncNode::PyFuncNode(const std::string& name): InlineFuncNode(name),_pyfunc(0)
 
 PyFuncNode::~PyFuncNode()
 {
-  DEBTRACE( getName() );
-  {
-    AutoGIL agil;
-    DEBTRACE( "_context refcnt: " << _context->ob_refcnt );
-    if(_pyfunc)DEBTRACE( "_pyfunc refcnt: " << _pyfunc->ob_refcnt );
-    Py_DECREF(_context);
-  }
   if(!CORBA::is_nil(_pynode))
     {
       _pynode->UnRegister();
@@ -673,142 +722,7 @@ void PyFuncNode::load()
 
 void PyFuncNode::loadRemote()
 {
-  DEBTRACE( "---------------PyfuncNode::loadRemote function---------------" );
-  bool isContAlreadyStarted(false);
-  if(_container)
-    {
-      isContAlreadyStarted=_container->isAlreadyStarted(this);
-      if(!isContAlreadyStarted)
-        {
-          try
-            {
-              _container->start(this);
-            }
-          catch(Exception& e)
-            {
-              _errorDetails=e.what();
-              throw e;
-            }
-        }
-    }
-  else
-    {
-      std::string what("PyFuncNode::loadRemote : a load operation requested on \"");
-      what+=_name; what+="\" with no container specified.";
-      _errorDetails=what;
-      throw Exception(what);
-    }
-
-  Engines::Container_var objContainer=Engines::Container::_nil();
-  if(!_container)
-    throw Exception("No container specified !");
-  SalomeContainer *containerCast0(dynamic_cast<SalomeContainer *>(_container));
-  SalomeHPContainer *containerCast1(dynamic_cast<SalomeHPContainer *>(_container));
-  if(containerCast0)
-    objContainer=containerCast0->getContainerPtr(this);
-  else if(containerCast1)
-    {
-      YACS::BASES::AutoCppPtr<SalomeContainerTmpForHP> tmpCont(SalomeContainerTmpForHP::BuildFrom(containerCast1,this));
-      objContainer=tmpCont->getContainerPtr(this);
-    }
-  else
-    throw Exception("Unrecognized type of container ! Salome one is expected ! In PythonNode !");
-  if(CORBA::is_nil(objContainer))
-    throw Exception("Container corba pointer is NULL ! In PythonNode !");
-  bool isInitializeRequested(false);
-  try
-    {
-      if(containerCast0)
-        {
-          _pynode = objContainer->createPyNode(getName().c_str(),getScript().c_str());
-        }
-      else
-        {
-          Engines::PyNode_var dftPyScript(objContainer->getDefaultPyNode());
-          if(CORBA::is_nil(dftPyScript))
-            {
-              isInitializeRequested=true;
-              _pynode = objContainer->createPyNode(getName().c_str(),getScript().c_str());
-            }
-          else
-            _pynode = dftPyScript;
-        }
-    }
-  catch( const SALOME::SALOME_Exception& ex )
-    {
-      std::string msg="Exception on remote python node creation ";
-      msg += '\n';
-      msg += ex.details.text.in();
-      _errorDetails=msg;
-      throw Exception(msg);
-    }
-
-  if(CORBA::is_nil(_pynode))
-    throw Exception("In PyFuncNode the ref in NULL ! ");
-
-  {
-    AutoGIL agil;
-    const char picklizeScript[]="import cPickle\n"
-        "def pickleForDistPyth2009(*args,**kws):\n"
-        "  return cPickle.dumps((args,kws),-1)\n"
-        "\n"
-        "def unPickleForDistPyth2009(st):\n"
-        "  args=cPickle.loads(st)\n"
-        "  return args\n";
-    PyObject *res=PyRun_String(picklizeScript,Py_file_input,_context,_context);
-    if(res == NULL)
-      {
-        _errorDetails="";
-        PyObject* new_stderr = newPyStdOut(_errorDetails);
-        PySys_SetObject((char*)"stderr", new_stderr);
-        PyErr_Print();
-        PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
-        Py_DECREF(new_stderr);
-        throw Exception("Error during load");
-      }
-    Py_DECREF(res);
-
-    _pyfuncSer=PyDict_GetItemString(_context,"pickleForDistPyth2009");
-    _pyfuncUnser=PyDict_GetItemString(_context,"unPickleForDistPyth2009");
-    if(_pyfuncSer == NULL)
-      {
-        _errorDetails="";
-        PyObject* new_stderr = newPyStdOut(_errorDetails);
-        PySys_SetObject((char*)"stderr", new_stderr);
-        PyErr_Print();
-        PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
-        Py_DECREF(new_stderr);
-        throw Exception("Error during load");
-      }
-    if(_pyfuncUnser == NULL)
-      {
-        _errorDetails="";
-        PyObject* new_stderr = newPyStdOut(_errorDetails);
-        PySys_SetObject((char*)"stderr", new_stderr);
-        PyErr_Print();
-        PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
-        Py_DECREF(new_stderr);
-        throw Exception("Error during load");
-      }
-    if(isInitializeRequested)
-      {//This one is called only once at initialization in the container if an init-script is specified.
-        try
-          {
-            std::string zeInitScriptKey(_container->getProperty(HomogeneousPoolContainer::INITIALIZE_SCRIPT_KEY));
-            if(!zeInitScriptKey.empty())
-              _pynode->executeAnotherPieceOfCode(zeInitScriptKey.c_str());
-          }
-        catch( const SALOME::SALOME_Exception& ex )
-          {
-            std::string msg="Exception on PythonNode::loadRemote python invocation of initializisation py script !";
-            msg += '\n';
-            msg += ex.details.text.in();
-            _errorDetails=msg;
-            throw Exception(msg);
-          }
-      }
-    DEBTRACE( "---------------End PyfuncNode::loadRemote function---------------" );
-  }
+  commonRemoteLoad(this);
 }
 
 void PyFuncNode::loadLocal()
@@ -1131,6 +1045,33 @@ Node *PyFuncNode::simpleClone(ComposedNode *father, bool editionOnly) const
   return new PyFuncNode(*this,father);
 }
 
+void PyFuncNode::createRemoteAdaptedPyInterpretor(Engines::Container_ptr objContainer)
+{
+  if(!CORBA::is_nil(_pynode))
+    _pynode->UnRegister();
+  _pynode=objContainer->createPyNode(getName().c_str(),getScript().c_str());
+}
+
+Engines::PyNodeBase_var PyFuncNode::retrieveDftRemotePyInterpretorIfAny(Engines::Container_ptr objContainer) const
+{
+  Engines::PyNode_var ret(objContainer->getDefaultPyNode());
+  if(!CORBA::is_nil(ret))
+    {
+      ret->Register();
+    }
+  return Engines::PyNodeBase::_narrow(ret);
+}
+
+void PyFuncNode::assignRemotePyInterpretor(Engines::PyNodeBase_var remoteInterp)
+{
+  _pynode=Engines::PyNode::_narrow(remoteInterp);
+}
+
+Engines::PyNodeBase_var PyFuncNode::getRemoteInterpreterHandle()
+{
+  return Engines::PyNodeBase::_narrow(_pynode);
+}
+
 //! Create a new node of same type with a given name
 PyFuncNode* PyFuncNode::cloneNode(const std::string& name)
 {
index 863961579695a05d68af47b97a501e49fd7eb8ce..8ccd4ec1cef75edb3d390d0214048e08219467d8 100644 (file)
@@ -24,6 +24,7 @@
 #include "InlineNode.hxx"
 #include <SALOMEconfig.h>
 #include CORBA_CLIENT_HEADER(SALOME_PyNode)
+#include CORBA_CLIENT_HEADER(SALOME_Component)
 
 #include <Python.h>
 
@@ -31,10 +32,34 @@ namespace YACS
 {
   namespace ENGINE
   {
-    class YACSRUNTIMESALOME_EXPORT PythonNode : public InlineNode 
+    class YACSRUNTIMESALOME_EXPORT PythonEntry
+    {
+    protected:
+      PythonEntry();
+      ~PythonEntry();
+      virtual void assignRemotePyInterpretor(Engines::PyNodeBase_var remoteInterp) = 0;
+      virtual Engines::PyNodeBase_var retrieveDftRemotePyInterpretorIfAny(Engines::Container_ptr objContainer) const = 0;
+      virtual void createRemoteAdaptedPyInterpretor(Engines::Container_ptr objContainer) = 0;
+      virtual Engines::PyNodeBase_var getRemoteInterpreterHandle() = 0;
+      virtual const char *getSerializationScript() const = 0;
+      //
+      void commonRemoteLoad(InlineNode *reqNode);
+    protected:
+      PyObject *_context;
+      PyObject *_pyfuncSer;
+      PyObject *_pyfuncUnser;
+    };
+
+    class YACSRUNTIMESALOME_EXPORT PythonNode : public InlineNode, public PythonEntry
     {
     protected:
       Node *simpleClone(ComposedNode *father, bool editionOnly) const;
+      // overload part of PythonEntry
+      void createRemoteAdaptedPyInterpretor(Engines::Container_ptr objContainer);
+      Engines::PyNodeBase_var retrieveDftRemotePyInterpretorIfAny(Engines::Container_ptr objContainer) const;
+      void assignRemotePyInterpretor(Engines::PyNodeBase_var remoteInterp);
+      Engines::PyNodeBase_var getRemoteInterpreterHandle();
+      const char *getSerializationScript() const  { return SCRIPT_FOR_SERIALIZATION; }
     public:
       PythonNode(const PythonNode& other, ComposedNode *father);
       PythonNode(const std::string& name);
@@ -49,20 +74,25 @@ namespace YACS
       virtual void shutdown(int level);
       std::string getContainerLog();
       PythonNode* cloneNode(const std::string& name);
+      virtual std::string typeName() { return "YACS__ENGINE__PythonNode"; }
+    public:
       static const char KIND[];
       static const char IMPL_NAME[];
-      virtual std::string typeName() {return "YACS__ENGINE__PythonNode";}
+      static const char SCRIPT_FOR_SERIALIZATION[];
     protected:
-      PyObject* _context;
-      PyObject* _pyfuncSer;
-      PyObject* _pyfuncUnser;
       Engines::PyScriptNode_var _pynode;
     };
 
-    class PyFuncNode : public InlineFuncNode 
+    class PyFuncNode : public InlineFuncNode, public PythonEntry
     {
     protected:
       Node *simpleClone(ComposedNode *father, bool editionOnly) const;
+      // overload part of PythonEntry
+      void createRemoteAdaptedPyInterpretor(Engines::Container_ptr objContainer);Engines::
+      PyNodeBase_var retrieveDftRemotePyInterpretorIfAny(Engines::Container_ptr objContainer) const;
+      void assignRemotePyInterpretor(Engines::PyNodeBase_var remoteInterp);
+      Engines::PyNodeBase_var getRemoteInterpreterHandle();
+      const char *getSerializationScript() const { return SCRIPT_FOR_SERIALIZATION; }
     public:
       PyFuncNode(const PyFuncNode& other, ComposedNode *father);
       PyFuncNode(const std::string& name);
@@ -77,12 +107,11 @@ namespace YACS
       virtual void shutdown(int level);
       std::string getContainerLog();
       PyFuncNode* cloneNode(const std::string& name);
-      virtual std::string typeName() {return "YACS__ENGINE__PyFuncNode";}
+      virtual std::string typeName() { return "YACS__ENGINE__PyFuncNode"; }
+    public:
+      static const char SCRIPT_FOR_SERIALIZATION[];
     protected:
-      PyObject* _context;
       PyObject* _pyfunc;
-      PyObject* _pyfuncSer;
-      PyObject* _pyfuncUnser;
       Engines::PyNode_var _pynode;
     };
   }