[doc] add documentation for the new API in test
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 27 Jun 2013 18:14:35 +0200
changeset 9119 cc85def2ac57
parent 9118 bb9e19df9a05
child 9120 fa513ac7a2a5
[doc] add documentation for the new API in test
doc/4.0.rst
--- a/doc/4.0.rst	Thu Jun 27 15:28:15 2013 +0200
+++ b/doc/4.0.rst	Thu Jun 27 18:14:35 2013 +0200
@@ -71,6 +71,37 @@
 The authentification stack have been altered to use the ``repoapi`` instead of
 the ``dbapi``. Cubes adding new element in this stack are likely to break.
 
+New API in test
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+All current methods and attributes used to access the repo on ``CubicwebTC`` are
+deprecated. You can now use a ``RepoAccess`` object. A ``RepoAccess`` object is
+linked to a new ``Session`` for a specified user. It is able to create
+``Connection``, ``ClientConnection`` and web side request linked to this
+session::
+
+    access =self.new_access("babar") # create a new RepoAccess for user babar
+    with access.repo_cnx() as cnx:
+        # some work with server side cnx
+        cnx.execute(…)
+        cnx.commit()
+        cnx.execute(…)
+        cnx.commit()
+
+    with access.client_cnx() as cnx:
+        # some work with client side cnx
+        cnx.execute(…)
+        cnx.commit()
+
+    with access.web_request(elephant="babar") as req:
+        # some work with client side cnx
+        elephant_name = req.form["elephant"]
+        req.execute(…)
+        req.cnx.commit()
+
+By default ``testcase.admin_access`` contains a ``RepoAccess`` object for the
+default admin session.
+
 
 API changes
 -----------