+
+void PickelizedPyObjServer::checkKeyPresence(PyObject *key, bool presence)
+{
+ if(!isDict())
+ throw Exception("PickelizedPyObjServer::checkKeyPresence : not a dict !");
+ PyObject *selfMeth(PyObject_GetAttrString(_self,"__contains__"));//new ref
+ PyObject *args(PyTuple_New(1));
+ PyTuple_SetItem(args,0,key); Py_XINCREF(key);// key is stolen by PyTuple_SetItem
+ PyObject *retPy(PyObject_CallObject(selfMeth,args));
+ Py_XDECREF(args);
+ Py_XDECREF(selfMeth);
+ //
+ if(retPy!=Py_False && retPy!=Py_True)
+ throw Exception("PickelizedPyObjServer::checkKeyPresence : unexpected return of dict.__contains__ !");
+ if(!presence)
+ {
+ if(retPy==Py_True)
+ throw Exception("PickelizedPyObjServer::checkKeyPresence : key is already present and it should not !");
+ }
+ else
+ {
+ if(retPy==Py_False)
+ throw Exception("PickelizedPyObjServer::checkKeyPresence : key is not present and it should !");
+ }
+ Py_XDECREF(retPy);
+}
+
+PickelizedPyObjServerModifiable::PickelizedPyObjServerModifiable(DataScopeServerBase *father, const std::string& varName, const SALOME::ByteVec& value):PickelizedPyObjServer(father,varName,value)
+{
+}
+
+PickelizedPyObjServerModifiable::PickelizedPyObjServerModifiable(DataScopeServerBase *father, const std::string& varName, PyObject *obj):PickelizedPyObjServer(father,varName,obj)
+{
+}
+
+void PickelizedPyObjServerModifiable::addKeyValueErrorIfAlreadyExisting(PyObject *key, PyObject *value)
+{
+ checkKeyNotAlreadyPresent(key);
+ bool isOK(PyDict_SetItem(_self,key,value)==0);
+ if(!isOK)
+ throw Exception("PickelizedPyObjServerModifiable::addKeyValueErrorIfAlreadyExisting : error when trying to add key,value to dict !");
+}
+
+void PickelizedPyObjServerModifiable::removeKeyInVarErrorIfNotAlreadyExisting(PyObject *key)
+{
+ checkKeyPresent(key);
+ if(PyDict_DelItem(_self,key)!=0)
+ throw Exception("PickelizedPyObjServerModifiable::removeKeyInVarErrorIfNotAlreadyExisting : error during deletion of key in dict !");
+}