[Cubicweb] commit and rollback on rqlcontroller

Jinpeng Li mr.li.jinpeng at gmail.com
Fri Jun 13 12:18:52 CEST 2014


Dear all,

Yesterday I worked with Yann for the indexation on database and we have
some feedback on rqlcontroller. When we insert an entity
with rqlcontroller, the mandatory relations of this entity should be
inserted as well, otherwise I will get error. It means each post already
commit, or rollback when it fails. Maybe cubicweb team needs to make it
stateless since it is RESTful Web services.

For example:

```
base_url = 'http://localhost:8080'
r = requests.Session()
a = r.get(base_url + "?__login=admin&__password=admin")
print a.status_code


url = base_url + "/rqlio/1.0"


args = [('INSERT Study ST: ST identifier "%s"' % study_id, {}),
              ('INSERT Subject SU: SU identifier "%s"' % subject_id, {}),
              ('SET SU related_studies ST WHERE ST eid %(t)s, SU eid %(u)s',
              {'t': '__r0', 'u':'__r1'}),]

a = requests.post(
                url,
                data=json.dumps(args),
                headers={'Content-Type': 'application/json'},
                verify=False,
                timeout=3)
```

However, this architecture makes it difficult to migrate from zmq/pyro to
the rqlcontroller. While an entity will be inserted, and its complicated
mandatory relations should be inserted in the meantime. We cannot first
insert entities and then insert their relations. I need to put all entities
and their relations in args which is difficult to read with '__r0' and
'__r1'. In addition, we don't have rollback operation.

Suggestion:
It is better to make rqlcontroller like a similar architecture to
the zmq/pyro method based on http session ID?
1: Easy migration from zmq/pyro to the rqlcontroller.
2: The rollback operation can easily restore database to a consistent
state after erroneous operations are performed.

Don't hesitate to correct me if I am wrong.

Regards,
Jinpeng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubicweb.org/pipermail/cubicweb/attachments/20140613/6e4673bd/attachment.html>


More information about the Cubicweb mailing list