string getAccessOfVar(in string varName) raises (SALOME::SALOME_Exception);
Transaction createRdOnlyVarTransac(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception);
Transaction createRdExtVarTransac(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception);
+ Transaction createRdExtInitVarTransac(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception);
Transaction createRdWrVarTransac(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception);
Transaction addKeyValueInVarHard(in string varName, in ByteVec keyValue, in ByteVec constValue) raises (SALOME::SALOME_Exception);
Transaction addKeyValueInVarErrorIfAlreadyExisting(in string varName, in ByteVec keyValue, in ByteVec constValue) raises (SALOME::SALOME_Exception);
varc->decrRef();
}
-void DataScopeServerBase::moveStatusOfVarFromRdExtToRdExtInit(const std::string& varName)
+void DataScopeServerBase::moveStatusOfVarFromRdExtOrRdExtInitToRdExtInit(const std::string& varName)
{
std::list< std::pair< SALOME::BasicDataServer_var, BasicDataServer * > >::iterator it(retrieveVarInternal4(varName));
std::pair< SALOME::BasicDataServer_var, BasicDataServer * >& p(*it);
- PickelizedPyObjRdExtServer *varc(dynamic_cast<PickelizedPyObjRdExtServer *>(p.second));
- if(!varc)
- throw Exception("DataScopeServerBase::moveStatusOfVarFromRdExtToRdExtInit : var is not a RdExt !");
- PyObject *pyobj(varc->getPyObj()); Py_XINCREF(pyobj);
- PickelizedPyObjRdExtInitServer *newVar(new PickelizedPyObjRdExtInitServer(this,varName,pyobj));
- CORBA::Object_var obj(newVar->activate());
- SALOME::BasicDataServer_var obj2(SALOME::BasicDataServer::_narrow(obj));
- p.first=obj2; p.second=newVar;
- varc->decrRef();
+ PickelizedPyObjRdExtServer *varc0(dynamic_cast<PickelizedPyObjRdExtServer *>(p.second));
+ PickelizedPyObjRdExtInitServer *varc1(dynamic_cast<PickelizedPyObjRdExtInitServer *>(p.second));
+ if(!varc0 && !varc1)
+ throw Exception("DataScopeServerBase::moveStatusOfVarFromRdExtOrRdExtInitToRdExtInit : var is neither RdExt nor RdExtInit !");
+ if(varc0)
+ {
+ PyObject *pyobj(varc0->getPyObj()); Py_XINCREF(pyobj);
+ PickelizedPyObjRdExtInitServer *newVar(new PickelizedPyObjRdExtInitServer(this,varName,pyobj));
+ CORBA::Object_var obj(newVar->activate());
+ SALOME::BasicDataServer_var obj2(SALOME::BasicDataServer::_narrow(obj));
+ p.first=obj2; p.second=newVar;
+ varc0->decrRef();
+ }
}
void DataScopeServerBase::moveStatusOfVarFromRdExtInitToRdExt(const std::string& varName)
_vars.push_back(p);
}
+void DataScopeServerTransaction::createRdExtInitVarInternal(const std::string& varName, const SALOME::ByteVec& constValue)
+{
+ checkNotAlreadyExistingVar(varName);
+ PickelizedPyObjRdExtInitServer *tmp(new PickelizedPyObjRdExtInitServer(this,varName,constValue));
+ CORBA::Object_var ret(tmp->activate());
+ std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp);
+ _vars.push_back(p);
+}
+
void DataScopeServerTransaction::createRdWrVarInternal(const std::string& varName, const SALOME::ByteVec& constValue)
{
checkNotAlreadyExistingVar(varName);
return SALOME::Transaction::_narrow(obj);
}
+SALOME::Transaction_ptr DataScopeServerTransaction::createRdExtInitVarTransac(const char *varName, const SALOME::ByteVec& constValue)
+{
+ checkNotAlreadyExistingVar(varName);
+ TransactionRdExtInitVarCreate *ret(new TransactionRdExtInitVarCreate(this,varName,constValue));
+ CORBA::Object_var obj(ret->activate());
+ return SALOME::Transaction::_narrow(obj);
+}
+
SALOME::Transaction_ptr DataScopeServerTransaction::createRdWrVarTransac(const char *varName, const SALOME::ByteVec& constValue)
{
checkNotAlreadyExistingVar(varName);
public:
void moveStatusOfVarFromRdWrToRdOnly(const std::string& varName);
void moveStatusOfVarFromRdOnlyToRdWr(const std::string& varName);
- void moveStatusOfVarFromRdExtToRdExtInit(const std::string& varName);
+ void moveStatusOfVarFromRdExtOrRdExtInitToRdExtInit(const std::string& varName);
void moveStatusOfVarFromRdExtInitToRdExt(const std::string& varName);
protected:
std::list< std::pair< SALOME::BasicDataServer_var, BasicDataServer * > >::const_iterator retrieveVarInternal3(const std::string& varName) const;
~DataScopeServerTransaction();
void createRdOnlyVarInternal(const std::string& varName, const SALOME::ByteVec& constValue);
void createRdExtVarInternal(const std::string& varName, const SALOME::ByteVec& constValue);
+ void createRdExtInitVarInternal(const std::string& varName, const SALOME::ByteVec& constValue);
void createRdWrVarInternal(const std::string& varName, const SALOME::ByteVec& constValue);
PortableServer::POA_var getPOA4KeyWaiter() const { return _poa_for_key_waiter; }
void addWaitKey(KeyWaiter *kw);
char *getAccessOfVar(const char *varName);
SALOME::Transaction_ptr createRdOnlyVarTransac(const char *varName, const SALOME::ByteVec& constValue);
SALOME::Transaction_ptr createRdExtVarTransac(const char *varName, const SALOME::ByteVec& constValue);
+ SALOME::Transaction_ptr createRdExtInitVarTransac(const char *varName, const SALOME::ByteVec& constValue);
SALOME::Transaction_ptr createRdWrVarTransac(const char *varName, const SALOME::ByteVec& constValue);
SALOME::Transaction_ptr addKeyValueInVarHard(const char *varName, const SALOME::ByteVec& key, const SALOME::ByteVec& value);
SALOME::Transaction_ptr addKeyValueInVarErrorIfAlreadyExisting(const char *varName, const SALOME::ByteVec& key, const SALOME::ByteVec& value);
const char PickelizedPyObjRdExtInitServer::ACCESS_REPR[]="RdExtInit";
+PickelizedPyObjRdExtInitServer::PickelizedPyObjRdExtInitServer(DataScopeServerBase *father, const std::string& varName, const SALOME::ByteVec& value):PickelizedPyObjServerModifiable(father,varName,value)
+{
+ _self_deep_copy=DeepCopyPyObj(_self);
+}
+
//! obj is consumed
PickelizedPyObjRdExtInitServer::PickelizedPyObjRdExtInitServer(DataScopeServerBase *father, const std::string& varName, PyObject *obj):PickelizedPyObjServerModifiable(father,varName,obj),_self_deep_copy(0)
{
class PickelizedPyObjRdExtInitServer : public PickelizedPyObjServerModifiable, public virtual POA_SALOME::PickelizedPyObjRdExtInitServer
{
public:
+ PickelizedPyObjRdExtInitServer(DataScopeServerBase *father, const std::string& varName, const SALOME::ByteVec& value);
PickelizedPyObjRdExtInitServer(DataScopeServerBase *father, const std::string& varName, PyObject *obj);
~PickelizedPyObjRdExtInitServer();
public:
_dsct->createRdExtVarInternal(_var_name,data2);
}
+void TransactionRdExtInitVarCreate::perform()
+{
+ SALOME::ByteVec data2;
+ FromVBToByteSeq(_data,data2);
+ _dsct->createRdExtInitVarInternal(_var_name,data2);
+}
+
void TransactionRdWrVarCreate::perform()
{
SALOME::ByteVec data2;
TransactionMultiKeyAddSession::TransactionMultiKeyAddSession(DataScopeServerTransaction *dsct, const std::string& varName):Transaction(dsct,varName)
{
- _dsct->moveStatusOfVarFromRdExtToRdExtInit(_var_name);
+ _dsct->moveStatusOfVarFromRdExtOrRdExtInitToRdExtInit(_var_name);
}
void TransactionMultiKeyAddSession::addKeyValueInVarErrorIfAlreadyExistingNow(const SALOME::ByteVec& key, const SALOME::ByteVec& value)
void perform();
};
+ class TransactionRdExtInitVarCreate : public TransactionVarCreate
+ {
+ public:
+ TransactionRdExtInitVarCreate(DataScopeServerTransaction *dsct, const std::string& varName, const SALOME::ByteVec& constValue):TransactionVarCreate(dsct,varName,constValue) { }
+ void perform();
+ };
+
class TransactionRdWrVarCreate : public TransactionVarCreate
{
public:
dsm.removeDataScope(scopeName)
pass
+ def testTransaction7(self):
+ """Like testTransaction5 but after a recovery."""
+ scopeName="Scope1"
+ varName="a"
+ dsm=salome.naming_service.Resolve("/DataServerManager")
+ dsm.cleanScopesInNS()
+ if scopeName in dsm.listScopes():
+ dsm.removeDataScope(scopeName)
+ dss,isCreated=dsm.giveADataScopeTransactionCalled(scopeName)
+ self.assertTrue(isCreated)
+ #
+ t0=dss.createRdExtInitVarTransac(varName,obj2Str({"ab":[4,5,6]}))
+ dss.atomicApply([t0])
+ #
+ self.assertEqual(dss.getAccessOfVar(varName),"RdExtInit")
+ t1=dss.addMultiKeyValueSession(varName)
+ self.assertEqual(dss.getAccessOfVar(varName),"RdExtInit")
+ t1.addKeyValueInVarErrorIfAlreadyExistingNow(obj2Str("cd"),obj2Str([7,8,9,10]))
+ self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6]})# it is not a bug ! commit of t1 not done !
+ dss.atomicApply([t1])
+ self.assertEqual(dss.getAccessOfVar(varName),"RdExt")
+ self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6],'cd':[7,8,9,10]})
+ pass
+
def setUp(self):
salome.salome_init()
pass