[Cubicweb] Which way to go to do remote RQL ?

Florent Cayré florent.cayre at logilab.fr
Fri Aug 8 08:42:44 CEST 2014


Hello Yann,

Le 08/08/2014 00:12, Yann Cointepas a écrit :
> [snip]
>
> db = CubicwebAPIWithRollback()
> try:
>     s = db.rql('INSERT Subject X: X identifier "N")[0][0]
>     db. rql('INSERT Scan X: X concerns S, S eid %d' % s)
>     s = db.rql('INSERT Subject X: X identifier "S")[0][0]
>     db. rql('INSERT Scan X: X concerns S, S eid %d' % s)
> except:
>     db.rollback()
> else:
>     db.commit()
>
> Because of the constraint error, there will be no change in the 
> database at the end of this code. How could I construct a code that 
> would do the same without transactions ?
>
> Sorry for this long message.
>
>       Yann
>
>

There is probably a misunderstanding here: rqlcontroller does not mean 
"no transaction" but rather "one transaction per web request".

Your simmplified example above fits perfectly with rqlcontroller 
capabilities, as illustrated in the rqlcontroller unittests : 
http://hg.logilab.org/review/cubes/rqlcontroller/file/948e9b500fe9/test/unittest_rqlcontroller.py#l38

Hope that helps.
Cheers,
Florent.



More information about the Cubicweb mailing list