]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
A full use case is runnable. Remaining : raise management, float, string
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 17 Nov 2014 16:32:31 +0000 (17:32 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 17 Nov 2014 16:32:31 +0000 (17:32 +0100)
idl/SALOME_SDS.idl
src/SALOMESDS/SALOMEGlobalVarHelper.py
src/SALOMESDS/SALOMESDS_DataScopeServer.cxx
src/SALOMESDS/SALOMESDS_DataScopeServer.hxx
src/SALOMESDS/SALOMESDS_StringDataServer.cxx
src/SALOMESDS/SALOMESDS_StringDataServer.hxx
src/SALOMESDS/SalomeSDSClt.py [new file with mode: 0644]
src/SALOMESDS/TestSalomeSDS1.py [new file with mode: 0644]

index 381d9947c14859224975c3b729762c9280a21ea2..76f45c8930b870d4195c4cc061ee5530b11a6761 100644 (file)
@@ -48,7 +48,7 @@ module SALOME
     string getScopeName();
     StringVec listVars();
     BasicDataServer retrieveVar(in string varName);
-    StringDataServer createGlobalStringVar(in string varName);
+    StringDataServer createGlobalStringVar(in string typeName, in string varName);
     StringDataServer createGlobalTmpVar(in ByteVec newValue);
     void shutdownIfNotHostedByDSM();
   };
index 8ceaf4522c59290998e92674e542451ada770d28..f4b6bbf5ab2d218935818dda8c25fcb360459d21 100644 (file)
 #
 # Author : Anthony Geay
 
+# dict,list,tuple,int,float,str
 import SALOME
 import cPickle
 
-class SALOMEGlobalVarHelper:
+class List(object):
     def __init__(self,varPtr,isTemporaryVar=False):
         assert(isinstance(varPtr,SALOME._objref_StringDataServer))
         self._var_ptr=varPtr
@@ -34,15 +35,104 @@ class SALOMEGlobalVarHelper:
     def __del__(self):
         self._var_ptr.UnRegister()
         pass
-    
+
+    def assign(self,elt):
+        st=cPickle.dumps(elt,cPickle.HIGHEST_PROTOCOL)
+        self._var_ptr.setSerializedContent(st)
+        pass
+
+    def __getitem__(self,*args):
+        ret=Caller(self._var_ptr,"__getitem__")
+        return ret(*args)
+
+    def __setitem__(self,*args):
+        ret=Caller(self._var_ptr,"__setitem__")
+        return ret(*args)
+
+    def append(self,*args):
+        ret=Caller(self._var_ptr,"append")
+        return ret(*args)
+
+    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.fetchSerializedContent())
+
+    def __reduce__(self):
+        return (list,(self.local_copy(),))
+
+    pass
+
+class Tuple(object):
+    def __init__(self,varPtr,isTemporaryVar=False):
+        assert(isinstance(varPtr,SALOME._objref_StringDataServer))
+        self._var_ptr=varPtr
+        if not isTemporaryVar:
+            self._var_ptr.Register()
+        self._is_temp=isTemporaryVar
+        pass
+
+    def __del__(self):
+        self._var_ptr.UnRegister()
+        pass
+
     def assign(self,elt):
         st=cPickle.dumps(elt,cPickle.HIGHEST_PROTOCOL)
         self._var_ptr.setSerializedContent(st)
         pass
+
+    def __getitem__(self,*args):
+        ret=Caller(self._var_ptr,"__getitem__")
+        return ret(*args)
+
+    def __setitem__(self,*args):
+        ret=Caller(self._var_ptr,"__setitem__")
+        return ret(*args)
+
+    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.fetchSerializedContent())
+
+    def __reduce__(self):
+        return (tuple,(self.local_copy(),))
+
+    pass
         
-    def __getattr__(self,meth):
-        #print "__getattr__,%s"%(meth)
-        return SALOMEGlobalVarMethodHelper(self._var_ptr,meth)
+
+class Int(object):
+    def __init__(self,varPtr,isTemporaryVar=False):
+        assert(isinstance(varPtr,SALOME._objref_StringDataServer))
+        self._var_ptr=varPtr
+        if not isTemporaryVar:
+            self._var_ptr.Register()
+        self._is_temp=isTemporaryVar
+        pass
+
+    def __del__(self):
+        self._var_ptr.UnRegister()
+        pass
+
+    def __iadd__(self,*args):
+        ret=Caller(self._var_ptr,"__add__")
+        return ret(*args)
+
+    def __isub__(self,*args):
+        ret=Caller(self._var_ptr,"__sub__")
+        return ret(*args)
+
+    def assign(self,elt):
+        st=cPickle.dumps(elt,cPickle.HIGHEST_PROTOCOL)
+        self._var_ptr.setSerializedContent(st)
+        pass
 
     def __str__(self):
         return self.local_copy().__str__()
@@ -51,27 +141,72 @@ class SALOMEGlobalVarHelper:
         return self.local_copy().__repr__()
 
     def local_copy(self):
-        return cPickle.loads(self._var_ptr.fetchSerializedContent())    
+        return cPickle.loads(self._var_ptr.fetchSerializedContent())
+
+    def __reduce__(self):
+        return (int,(self.local_copy(),))
+
     pass
 
-class SALOMEGlobalVarMethodHelper:
+class Dict(object):
+    def __init__(self,varPtr,isTemporaryVar=False):
+        assert(isinstance(varPtr,SALOME._objref_StringDataServer))
+        self._var_ptr=varPtr
+        if not isTemporaryVar:
+            self._var_ptr.Register()
+        self._is_temp=isTemporaryVar
+        pass
+
+    def __del__(self):
+        self._var_ptr.UnRegister()
+        pass
+
+    def assign(self,elt):
+        st=cPickle.dumps(elt,cPickle.HIGHEST_PROTOCOL)
+        self._var_ptr.setSerializedContent(st)
+        pass
+
+    def __getitem__(self,*args):
+        ret=Caller(self._var_ptr,"__getitem__")
+        return ret(*args)
+
+    def __setitem__(self,*args):
+        ret=Caller(self._var_ptr,"__setitem__")
+        return ret(*args)
+
+    def __len__(self):
+        return len(self.local_copy())
+
+    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.fetchSerializedContent())
+
+    def __reduce__(self):
+        return (dict,(self.local_copy(),))
+
+    pass
+
+class Caller:
     def __init__(self,varPtr,meth):
         assert(isinstance(varPtr,SALOME._objref_StringDataServer))
         self._var_ptr=varPtr
-        self._var_ptr.Register()
         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))
-        ret=SALOMEGlobalVarHelper(ret,True)
-        if self._meth not in ["__len__","__coerce__"]:
-            return ret
-        else:
-            return ret.local_copy()
-
-    def __del__(self):
-        self._var_ptr.UnRegister()
-        pass
+        return GetHandlerFromRef(ret,True)
     pass
+
+PyHandlerTypeMap={int:Int,list:List,tuple:Tuple,dict:Dict}
+
+def GetHandlerFromRef(objCorba,isTempVar=False):
+    v=cPickle.loads(objCorba.fetchSerializedContent())
+    if v is None:
+        return None
+    return PyHandlerTypeMap[v.__class__](objCorba,isTempVar)
index 7b529a59fb57065389b7203ffb3e92aa42cb5129..5b3cfc1c2ce378fb969f81c381d5835ea305f00c 100644 (file)
@@ -103,9 +103,9 @@ SALOME::BasicDataServer_ptr DataScopeServer::retrieveVar(const char *varName)
 /*!
  * Called remotely -> to protect against throw
  */
-SALOME::StringDataServer_ptr DataScopeServer::createGlobalStringVar(const char *varName)
+SALOME::StringDataServer_ptr DataScopeServer::createGlobalStringVar(const char *typeName, const char *varName)
 {
-  std::string varNameCpp(varName);
+  std::string varNameCpp(varName),typeNameCpp(typeName);
   std::vector<std::string> allNames(getAllVarNames());
   std::vector<std::string>::iterator it(std::find(allNames.begin(),allNames.end(),varNameCpp));
   if(it!=allNames.end())
@@ -113,7 +113,7 @@ SALOME::StringDataServer_ptr DataScopeServer::createGlobalStringVar(const char *
       std::ostringstream oss; oss << "DataScopeServer::createGlobalStringVar : name \"" << varNameCpp << "\" already exists !";
       throw Exception(oss.str());
     }
-  AutoRefCountPtr<StringDataServer> tmp(new StringDataServer(this,varNameCpp));
+  AutoRefCountPtr<StringDataServer> tmp(new StringDataServer(this,typeNameCpp,varNameCpp));
   CORBA::Object_var ret(activateWithDedicatedPOA(tmp));
   std::pair< SALOME::BasicDataServer_var, AutoRefCountPtr<BasicDataServer> > p(SALOME::BasicDataServer::_narrow(ret),DynamicCastSafe<StringDataServer,BasicDataServer>(tmp));
   _vars.push_back(p);
@@ -127,9 +127,8 @@ SALOME::StringDataServer_ptr DataScopeServer::createGlobalTmpVar(const SALOME::B
 {
   static const char TMP_VAR_NAME[]="TmP";
   std::string vn(BuildTmpVarNameFrom(TMP_VAR_NAME));
-  StringDataServer *retCpp(new StringDataServer(this,vn));
+  StringDataServer *retCpp(new StringDataServer(this,vn,newValue));
   retCpp->setPOA(_poa);
-  retCpp->setSerializedContent(newValue);
   //
   PortableServer::ObjectId_var id(_poa->activate_object(retCpp));
   CORBA::Object_var ret(_poa->id_to_reference(id));
index ca4976d1a160d9a5341fb6881388c246e9aefe7a..6f50f68c008d21602ebe17a930a7bad396b62039 100644 (file)
@@ -45,7 +45,7 @@ namespace SALOMESDS
     char *getScopeName();
     SALOME::StringVec *listVars();
     SALOME::BasicDataServer_ptr retrieveVar(const char *varName);
-    SALOME::StringDataServer_ptr createGlobalStringVar(const char *varName);
+    SALOME::StringDataServer_ptr createGlobalStringVar(const char *typeName, const char *varName);
     SALOME::StringDataServer_ptr createGlobalTmpVar(const SALOME::ByteVec& newValue);
     void shutdownIfNotHostedByDSM();
     ~DataScopeServer();
index 77e5796e1f63b085fb49fa9c34e81eb97984f388..87b155a67db40770ffcd8490c1b94fd83e303804 100644 (file)
 
 using namespace SALOMESDS;
 
-StringDataServer::StringDataServer(DataScopeServer *father, const std::string& varName):BasicDataServer(father,varName),_self(Py_None)
+StringDataServer::StringDataServer(DataScopeServer *father, const std::string& typeName, const std::string& varName):BasicDataServer(father,varName),_self(0)
 {
-  Py_XINCREF(Py_None);
+  _self=CreateDftObjFromType(father->getGlobals(),typeName);
+}
+
+StringDataServer::StringDataServer(DataScopeServer *father, const std::string& varName, const SALOME::ByteVec& value):BasicDataServer(father,varName),_self(0)
+{
+  setSerializedContentInternal(value);
 }
 
 //! obj is consumed
@@ -48,10 +53,7 @@ StringDataServer::~StringDataServer()
  */
 void StringDataServer::setSerializedContent(const SALOME::ByteVec& newValue)
 {
-  checkReadOnlyStatusRegardingConstness("StringDataServer::setSerializedContent : read only var !");
-  std::string data;
-  FromByteSeqToCpp(newValue,data);
-  setNewPyObj(getPyObjFromPickled(data));
+  setSerializedContentInternal(newValue);
 }
 
 /*!
@@ -167,3 +169,31 @@ void StringDataServer::setNewPyObj(PyObject *obj)
   Py_XDECREF(_self);
   _self=obj;
 }
+
+void StringDataServer::setSerializedContentInternal(const SALOME::ByteVec& newValue)
+{
+  checkReadOnlyStatusRegardingConstness("StringDataServer::setSerializedContent : read only var !");
+  std::string data;
+  FromByteSeqToCpp(newValue,data);
+  setNewPyObj(getPyObjFromPickled(data));
+}
+
+PyObject *StringDataServer::CreateDftObjFromType(PyObject *globals, const std::string& typeName)
+{
+  PyObject *builtins(PyDict_GetItemString(globals,"__builtins__"));
+  if(!builtins)
+    throw Exception("StringDataServer constructor : no __builtins__ in globals !");
+  PyObject *builtins2(PyModule_GetDict(builtins));
+  if(!builtins2)
+    throw Exception("StringDataServer constructor : internal error fail to invoke __dict__ on __builtins__ !");
+  PyObject *tmp(PyDict_GetItemString(builtins2,typeName.c_str()));
+  if(!tmp)
+    {
+      std::ostringstream oss; oss << "StringDataServer::CreateDftObjFromType : Invalid type name \"" << typeName << "\" !";
+      throw Exception(oss.str());
+    }
+  PyObject *args(PyTuple_New(0));
+  PyObject *ret(PyObject_CallObject(tmp,args));
+  Py_XDECREF(args);
+  return ret;
+}
index bb266a05841fb3135de4c508b1fbcf5cd93822cc..0385cebaf102b4332ab0a27743db44e3241af7d8 100644 (file)
@@ -33,7 +33,8 @@ namespace SALOMESDS
   class StringDataServer : public BasicDataServer, public virtual POA_SALOME::StringDataServer
   {
   public:
-    StringDataServer(DataScopeServer *father, const std::string& varName);
+    StringDataServer(DataScopeServer *father, const std::string& typeName, const std::string& varName);
+    StringDataServer(DataScopeServer *father, const std::string& varName, const SALOME::ByteVec& value);
     StringDataServer(DataScopeServer *father, const std::string& varName, PyObject *obj);
     ~StringDataServer();
     void setSerializedContent(const SALOME::ByteVec& newValue);
@@ -48,6 +49,8 @@ namespace SALOMESDS
     PyObject *getPyObjFromPickled(const std::string& pickledData);
     std::string pickelize(PyObject *obj);
     void setNewPyObj(PyObject *obj);
+    void setSerializedContentInternal(const SALOME::ByteVec& newValue);
+    static PyObject *CreateDftObjFromType(PyObject *globals, const std::string& typeName);
   private:
     static const char FAKE_VAR_NAME_FOR_WORK[];
     PyObject *_self;
diff --git a/src/SALOMESDS/SalomeSDSClt.py b/src/SALOMESDS/SalomeSDSClt.py
new file mode 100644 (file)
index 0000000..50e83ca
--- /dev/null
@@ -0,0 +1,220 @@
+#  -*- 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
+
+# dict,list,tuple,int,float,str
+import SALOME
+import cPickle
+
+class List(object):
+    def __init__(self,varPtr,isTemporaryVar=False):
+        assert(isinstance(varPtr,SALOME._objref_StringDataServer))
+        self._var_ptr=varPtr
+        if not isTemporaryVar:
+            self._var_ptr.Register()
+        self._is_temp=isTemporaryVar
+        pass
+
+    def __del__(self):
+        self._var_ptr.UnRegister()
+        pass
+
+    def assign(self,elt):
+        st=cPickle.dumps(elt,cPickle.HIGHEST_PROTOCOL)
+        self._var_ptr.setSerializedContent(st)
+        pass
+
+    def __getitem__(self,*args):
+        ret=Caller(self._var_ptr,"__getitem__")
+        return ret(*args)
+
+    def __setitem__(self,*args):
+        ret=Caller(self._var_ptr,"__setitem__")
+        return ret(*args)
+
+    def append(self,*args):
+        ret=Caller(self._var_ptr,"append")
+        return ret(*args)
+
+    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.fetchSerializedContent())
+
+    def __reduce__(self):
+        return (list,(self.local_copy(),))
+
+    pass
+
+class Tuple(object):
+    def __init__(self,varPtr,isTemporaryVar=False):
+        assert(isinstance(varPtr,SALOME._objref_StringDataServer))
+        self._var_ptr=varPtr
+        if not isTemporaryVar:
+            self._var_ptr.Register()
+        self._is_temp=isTemporaryVar
+        pass
+
+    def __del__(self):
+        self._var_ptr.UnRegister()
+        pass
+
+    def assign(self,elt):
+        st=cPickle.dumps(elt,cPickle.HIGHEST_PROTOCOL)
+        self._var_ptr.setSerializedContent(st)
+        pass
+
+    def __getitem__(self,*args):
+        ret=Caller(self._var_ptr,"__getitem__")
+        return ret(*args)
+
+    def __setitem__(self,*args):
+        ret=Caller(self._var_ptr,"__setitem__")
+        return ret(*args)
+
+    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.fetchSerializedContent())
+
+    def __reduce__(self):
+        return (tuple,(self.local_copy(),))
+
+    pass
+        
+
+class Int(object):
+    def __init__(self,varPtr,isTemporaryVar=False):
+        assert(isinstance(varPtr,SALOME._objref_StringDataServer))
+        self._var_ptr=varPtr
+        if not isTemporaryVar:
+            self._var_ptr.Register()
+        self._is_temp=isTemporaryVar
+        pass
+
+    def __del__(self):
+        self._var_ptr.UnRegister()
+        pass
+
+    def __iadd__(self,*args):
+        ret=Caller(self._var_ptr,"__add__")
+        return ret(*args)
+
+    def __isub__(self,*args):
+        ret=Caller(self._var_ptr,"__sub__")
+        return ret(*args)
+
+    def assign(self,elt):
+        st=cPickle.dumps(elt,cPickle.HIGHEST_PROTOCOL)
+        self._var_ptr.setSerializedContent(st)
+        pass
+
+    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.fetchSerializedContent())
+
+    def __reduce__(self):
+        return (int,(self.local_copy(),))
+
+    pass
+
+class Dict(object):
+    def __init__(self,varPtr,isTemporaryVar=False):
+        assert(isinstance(varPtr,SALOME._objref_StringDataServer))
+        self._var_ptr=varPtr
+        if not isTemporaryVar:
+            self._var_ptr.Register()
+        self._is_temp=isTemporaryVar
+        pass
+
+    def __del__(self):
+        self._var_ptr.UnRegister()
+        pass
+
+    def assign(self,elt):
+        st=cPickle.dumps(elt,cPickle.HIGHEST_PROTOCOL)
+        self._var_ptr.setSerializedContent(st)
+        pass
+
+    def __getitem__(self,*args):
+        ret=Caller(self._var_ptr,"__getitem__")
+        return ret(*args)
+
+    def __setitem__(self,*args):
+        ret=Caller(self._var_ptr,"__setitem__")
+        return ret(*args)
+
+    def __len__(self):
+        return len(self.local_copy())
+
+    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.fetchSerializedContent())
+
+    def __reduce__(self):
+        return (dict,(self.local_copy(),))
+
+    pass
+
+class Caller:
+    def __init__(self,varPtr,meth):
+        assert(isinstance(varPtr,SALOME._objref_StringDataServer))
+        self._var_ptr=varPtr
+        self._meth=meth
+        pass
+
+    def __call__(self,*args):
+        ret=self._var_ptr.invokePythonMethodOn(self._meth,cPickle.dumps(args,cPickle.HIGHEST_PROTOCOL))
+        return GetHandlerFromRef(ret,True)
+    pass
+
+PyHandlerTypeMap={int:Int,list:List,tuple:Tuple,dict:Dict}
+
+def GetHandlerFromRef(objCorba,isTempVar=False):
+    """ Returns a client that allows to handle a remote corba ref of a global var easily.
+    """
+    v=cPickle.loads(objCorba.fetchSerializedContent())
+    if v is None:
+        return None
+    return PyHandlerTypeMap[v.__class__](objCorba,isTempVar)
+
+def GetHandlerFromName(scopeName,varName):
+    import salome
+    dsm=salome.naming_service.Resolve("/DataServerManager")
+    d2s=dsm.giveADataScopeCalled(scopeName)
+    return GetHandlerFromRef(d2s.retrieveVar("a"),False)
diff --git a/src/SALOMESDS/TestSalomeSDS1.py b/src/SALOMESDS/TestSalomeSDS1.py
new file mode 100644 (file)
index 0000000..4951c98
--- /dev/null
@@ -0,0 +1,102 @@
+#  -*- 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 SALOME
+import cPickle
+import gc
+import SalomeSDSClt
+
+st="jjj"
+dsm=salome.naming_service.Resolve("/DataServerManager")
+assert(dsm.isAliveAndKicking("Default"))
+assert(isinstance(dsm,SALOME._objref_DataServerManager))
+assert(isinstance(dsm.getDefaultScope(),SALOME._objref_DataScopeServer))
+d2s=dsm.createDataScope("tonyy")
+assert(isinstance(d2s,SALOME._objref_DataScopeServer))
+a=d2s.createGlobalStringVar("int","c")
+assert(a.getVarName()=="c")
+#
+a.setSerializedContent(cPickle.dumps(st,cPickle.HIGHEST_PROTOCOL))
+assert(cPickle.loads(a.fetchSerializedContent())==st)
+assert(cPickle.loads(a.fetchSerializedContent())==st)
+assert(cPickle.loads(d2s.retrieveVar("c").fetchSerializedContent())==st)
+assert(isinstance(d2s.retrieveVar("c"),SALOME._objref_StringDataServer))
+assert(dsm.listScopes()==['Default','tonyy'])
+dsm.createDataScope("S2")
+assert(dsm.retriveDataScope("S2").getScopeName()=="S2")
+assert(dsm.listScopes()==['Default','tonyy','S2'])
+dsm.removeDataScope("Default")
+assert(dsm.listScopes()==['tonyy','S2'])
+dsm.removeDataScope("tonyy")
+assert(dsm.listScopes()==['S2'])
+a=dsm.retriveDataScope("S2").createGlobalStringVar("int","a")
+#
+sname="S7"
+dsm=salome.naming_service.Resolve("/DataServerManager")
+st=cPickle.dumps([],cPickle.HIGHEST_PROTOCOL)
+a=dsm.giveADataScopeCalled(sname).createGlobalStringVar("list","a")
+dsm.giveADataScopeCalled(sname)
+a.setSerializedContent(cPickle.dumps((0,),cPickle.HIGHEST_PROTOCOL))
+assert(cPickle.loads(a.fetchSerializedContent())==(0,))
+a.setSerializedContent(st)
+assert(cPickle.loads(a.fetchSerializedContent())==[])
+tmp=a.invokePythonMethodOn("append",cPickle.dumps((0,),cPickle.HIGHEST_PROTOCOL))
+assert(cPickle.loads(a.fetchSerializedContent())==[0])
+for i in xrange(0,1000):
+    tmp=a.invokePythonMethodOn("append",cPickle.dumps((i,),cPickle.HIGHEST_PROTOCOL))
+    pass
+dsm.removeDataScope(sname)
+#
+sname="S4"
+d2s=dsm.giveADataScopeCalled(sname)
+d2s.createGlobalStringVar("list","a")
+a=SalomeSDSClt.GetHandlerFromRef(dsm.retriveDataScope(sname).retrieveVar("a"))
+a.append(1)
+for i in xrange(1000):
+    a.append(i)
+    pass
+assert(sum(a.local_copy())==499501)
+assert(dsm.isAliveAndKicking(sname))
+#
+dsm=salome.naming_service.Resolve("/DataServerManager")
+sname="S11"
+d2s=dsm.giveADataScopeCalled(sname)
+d2s.createGlobalStringVar("dict","a")
+a=SalomeSDSClt.GetHandlerFromName(sname,"a")
+assert(isinstance(a,SalomeSDSClt.Dict))
+a.assign({})
+a["ab"]=45 ; gc.collect(0)
+a["cd"]=[4,5] ; gc.collect(0)
+a["cd"].append(77) ; gc.collect(0)
+a["cd"].append([4,7,8]) ; gc.collect(0)
+a["cd"][3].append(3) ; gc.collect(0)
+a["ab"]+=2
+assert(a.local_copy()=={'ab':47,'cd':[4,5,77,[4,7,8,3]]})
+a["ab"]-=1
+assert(a.local_copy()=={'ab':46,'cd':[4,5,77,[4,7,8,3]]})
+assert(len(a)==2)
+c=a["cd"] ; gc.collect(0)
+assert(isinstance(c,SalomeSDSClt.List))
+a["cd"]=26 ; gc.collect(0)
+assert(a.local_copy()=={'ab':46,'cd':26})
+a["cd"]=c
+assert(a.local_copy()=={'ab':46,'cd':[4,5,77,[4,7,8,3]]})