]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
A good version. TODO : 1 - multi levels management 2 - clean exception handling
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 30 Oct 2014 15:19:09 +0000 (16:19 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 30 Oct 2014 15:19:09 +0000 (16:19 +0100)
src/SALOMESDS/SALOMEGlobalVarHelper.py [new file with mode: 0644]
src/SALOMESDS/SALOMESDS_StringDataServer.cxx

diff --git a/src/SALOMESDS/SALOMEGlobalVarHelper.py b/src/SALOMESDS/SALOMEGlobalVarHelper.py
new file mode 100644 (file)
index 0000000..d551f78
--- /dev/null
@@ -0,0 +1,61 @@
+#  -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2014  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author : Anthony Geay
+
+import SALOME
+import cPickle
+
+class SALOMEGlobalVarMethodHelper:
+    def __init__(self,varPtr,meth):
+        assert(isinstance(varPtr,SALOME._objref_StringDataServer))
+        self._var_ptr=varPtr
+        self._meth=meth
+        pass
+
+    def __call__(self,*args):
+        #print "__call__ %s : %s"%(self._meth,str(args))
+        ret=self._var_ptr.invokePythonMethodOn(self._meth,cPickle.dumps(args,cPickle.HIGHEST_PROTOCOL))
+        return cPickle.loads(ret)
+    pass
+
+class SALOMEGlobalVarHelper:
+    def __init__(self,varPtr):
+        assert(isinstance(varPtr,SALOME._objref_StringDataServer))
+        self._var_ptr=varPtr
+        pass
+    
+    def assign(self,elt):
+        st=cPickle.dumps(elt,cPickle.HIGHEST_PROTOCOL)
+        self._var_ptr.setValueOf(st)
+        pass
+        
+    def __getattr__(self,*args):
+        #print "__getattr__,%s"%(str(args))
+        return SALOMEGlobalVarMethodHelper(self._var_ptr,args[0])
+
+    def __str__(self):
+        return self.local_copy().__str__()
+
+    def __repr__(self):
+        return self.local_copy().__repr__()
+
+    def local_copy(self):
+        return cPickle.loads(self._var_ptr.getValueOf())    
+    pass
index 805a2153b3bde8ca789d802dfe3f340971706d1f..40da23cf3d8edcd5d5871568261e795a5ced2abb 100644 (file)
@@ -68,6 +68,11 @@ SALOME::ByteVec *StringDataServer::invokePythonMethodOn(const char *method, cons
       throw Exception(oss.str());
     }
   PyObject *res(PyObject_CallObject(selfMeth,argsPy));
+  if(!res)
+    {
+      std::ostringstream oss; oss << "StringDataServer::invokePythonMethodOn : Problem during invokation serverside of Method \"" << method << "\" !";
+      throw Exception(oss.str());
+    }
   _data=pickelize(self);// if it is a non const method !
   std::string retCpp(pickelize(res));
   // to test : res and self