[Cubicweb] Rework of the Repository Access API (Session, Transaction, Connection, Cursors, Request and other mess)

Pierre-Yves David pierre-yves.david at logilab.fr
Mon May 27 17:43:00 CEST 2013


Dear list,

You probably wanna have a look at https://www.cubicweb.org/2503918

There is the ticket text for discussion:

The current architecture will receive a major rework. The current architecture
basically looks like::


    SERVER SIDE                               DBAPI SIDE

    /---------------\ 1                     ? /---------------\
    | Session       |-------------------------| Connection    |
    \---------------/                         \---------------/
            | 1                                      | 1
            | (dispatch on thread name)              |  (dispatch on thread name)
            | *                                      | *
    /---------------\                         /---------------\
    |TransactionData|                         |    Request    |
    \---------------/                         |       +       |
            | ?                               |    Cursors    |
            |                                 \---------------/
            | 1
    /---------------\
    | Cnx Set       |
    \---------------/

In practice two objects are actually used, Session server-side and Request client-side. All the chain makes insane use of thread based dispatching to end up using
the right TransactionData object.

Another important issue is that the so-called DBAPI has hardly anything to do
with the actual stdlib DBAPI.

---

The new proposal is to drop ``cubicweb.dbapi`` and move to the following schema::


    SERVER SIDE                               CLIENT SIDE

    /---------------\
    | Session       |
    \---------------/
            | 1
            |
            | *
    /---------------\ 1                     ? /---------------\
    |  Connection   |-------------------------|    Request    |
    \---------------/                         \---------------/
            | ?
            |
            | 1
    /---------------\
    | Cnx Set       |
    \---------------/


``Session`` will become a long lived object holding Credential (user) and long
living data (session_data).

``Connection`` will be the main entry point on the server side. it will allow all necessary
read and write operations server side. It is performing at most one database
transaction at any given time but can be used for multiple sequential transactions.
A Connection has explicit start and end. The name ``Transaction`` is **not
used** for this object as multiple Transaction can occur. Naming it
``Connection`` matches how such objects are named in a standard database context.

``Request`` objects now directly reference a server-side Connection object.

``Cursor``: the name has been discarded as it refers to a DBAPI concept
we do not have in Cubicweb.


---

At some point in the future we will want to split the Request object in two. One
object dedicated to Cubicweb repository operations ``ClientConnection`` and one
related to http request processing ``WebRequest``::


    SERVER SIDE                               CLIENT SIDE

    /---------------\
    | Session       |
    \---------------/
            | 1
            |
            | *
    /---------------\ 1                     ? /------------------\
    |  Connection   |-------------------------| ClientConnection |
    \---------------/                         \------------------/
            | ?                                       | 1
            |                                         |
            | 1                                       | ?
    /---------------\                         /---------------\
    | Cnx Set       |                         | WebRequest    |
    \---------------/                         \---------------/

In distant future ``ClientConnection`` may be dropped in favor of direct usage
of ``Connection``.


What do you guys think

-- 
Pierre-Yves David

http://www.logilab.fr/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.cubicweb.org/pipermail/cubicweb/attachments/20130527/ea68f157/attachment-0186.sig>


More information about the Cubicweb mailing list