doc/3.19.rst
changeset 9405 7fc5e13d049f
parent 9404 3e3e9b37e177
child 9486 9a62c52d167e
equal deleted inserted replaced
9404:3e3e9b37e177 9405:7fc5e13d049f
     1 What's new in CubicWeb 4.0?
     1 What's new in CubicWeb 3.19?
     2 ============================
     2 ============================
     3 
     3 
     4 Behavior Changes
     4 Behaviour Changes
     5 ----------------
     5 -----------------
     6 
     6 
     7 * The anonymous property of Session and Connection are now computed from the
     7 * The anonymous property of Session and Connection are now computed from the
     8   related user login. If it match the ``anonymous-user`` in the config the
     8   related user login. If it matches the ``anonymous-user`` in the config the
     9   connection is anonymous. Beware that the ``anonymous-user`` config is web
     9   connection is anonymous. Beware that the ``anonymous-user`` config is web
    10   specific. Therefore, no session may be anonymous in repository only setup.
    10   specific. Therefore, no session may be anonymous in a repository only setup.
       
    11 
    11 
    12 
    12 New Repository Access API
    13 New Repository Access API
    13 -------------------------
    14 -------------------------
    14 
    15 
    15 Connection replace Session
    16 Connection replaces Session
    16 ~~~~~~~~~~~~~~~~~~~~~~~~~~
    17 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    17 
    18 
    18 A new explicite Connection object replace Session as the main repository entry
    19 A new explicit Connection object replaces Session as the main repository entry
    19 point. Connection hold all the necessary methods to be used Server side
    20 point. Connection holds all the necessary methods to be used server-side
    20 (``execute``, ``commit``, ``rollback``, ``call_service``, ``entity_from_eid``,
    21 (``execute``, ``commit``, ``rollback``, ``call_service``, ``entity_from_eid``,
    21 etc…). You obtains a new Connection object using ``session.new_cnx()``.
    22 etc...). One obtains a new Connection object using ``session.new_cnx()``.
    22 Connection object need have an explicite begin and end. Use them as a context
    23 Connection objects need to have an explicit begin and end. Use them as a context
    23 manager::
    24 manager to never miss an end::
    24 
    25 
    25     with session.new_cnx() as cnx:
    26     with session.new_cnx() as cnx:
    26         self.execute('INSERT Elephant E, E name "Cabar"')
    27         self.execute('INSERT Elephant E, E name "Cabar"')
    27         self.commit()
    28         self.commit()
    28         self.execute('INSERT Elephant E, E name "Celeste"')
    29         self.execute('INSERT Elephant E, E name "Celeste"')
    29         self.commit()
    30         self.commit()
    30     # Once you get out of the "with" clause, the connection is closed.
    31     # Once you get out of the "with" clause, the connection is closed.
    31 
    32 
    32 Using the same Connection object in multiple threads will give you access to the
    33 Using the same Connection object in multiple threads will give you access to the
    33 same Transaction. However, Connection object are not thread safe.
    34 same Transaction. However, Connection objects are not thread safe (hence at your
       
    35 own risks).
    34 
    36 
    35 ``repository.internal_session`` is deprecated in favor of
    37 ``repository.internal_session`` is deprecated in favor of
    36 ``repository.internal_cnx``. Note that internal connection are now safe.
    38 ``repository.internal_cnx``. Note that internal connections are now `safe` by default,
    37 Integrity hooks are enabled.
    39 i.e. the integrity hooks are enabled.
    38 
    40 
    39 Backward compact is preserved on Session. They can still be used to access the
    41 Backward compatibility is preserved on Session.
    40 database for the next few version.
    42 
    41 
    43 
    42 dbapi vs repoapi
    44 dbapi vs repoapi
    43 ~~~~~~~~~~~~~~~~
    45 ~~~~~~~~~~~~~~~~
    44 
    46 
    45 A new API have been introduced to replace the dbapi. It is called "repoapi".
    47 A new API has been introduced to replace the dbapi. It is called `repoapi`.
    46 
    48 
    47 there is three relevant function for now:
    49 There are three relevant functions for now:
    48 
    50 
    49 ``repoapi.get_repository(config)`` takes a config object and return credential
    51 * ``repoapi.get_repository(config)`` takes a config object and return credential
    50 
    52 
    51 ``repoapi.connect(repo, **credential)`` return a ClientConnection associated to
    53 * ``repoapi.connect(repo, **credentials)`` returns a ClientConnection
    52 the user identified by the credential. The ClientConnection is associated to its
    54   associated with the user identified by the credentials. The
    53 own Session that is closed when the ClientConnection is closed. A
    55   ClientConnection is associated with its own Session that is closed
    54 ClientConnection is a Connection-like object to be used client side.
    56   when the ClientConnection is closed. A ClientConnection is a
       
    57   Connection-like object to be used client side.
    55 
    58 
    56 ``repoapi.anonymous_cnx(repo)`` return a ClientConnection associated to the
    59 * ``repoapi.anonymous_cnx(repo)`` returns a ClientConnection associated
    57 anonymous user if describe in the Config.
    60   with the anonymous user if describe in the Config.
       
    61 
    58 
    62 
    59 repoapi.ClientConnection replace dbapi.Connection and company
    63 repoapi.ClientConnection replace dbapi.Connection and company
    60 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    64 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    61 
    65 
    62 On the client/web side, the Request is now using a ``repoapi.ClientConnection``
    66 On the client/web side, the Request is now using a ``repoapi.ClientConnection``
    63 instead of a ``dbapi.connection``. The ``ClientConnection`` have multiple backward
    67 instead of a ``dbapi.connection``. The ``ClientConnection`` has multiple backward
    64 compat method to looks like a ``dbapi.Cursor`` and ``dbapi.Connection``. It will
    68 compatible methods to make it look like a ``dbapi.Cursor`` and ``dbapi.Connection``.
    65 remain that way for a few version.
       
    66 
    69 
    67 Session used on the Web side are now the same than the one used Server side.
    70 Session used on the Web side are now the same than the one used Server side.
    68 Some backward compat method have been installed on the server side Session to
    71 Some backward compatibility methods have been installed on the server side Session
    69 ease the transition.
    72 to ease the transition.
    70 
    73 
    71 The authentification stack have been altered to use the ``repoapi`` instead of
    74 The authentication stack has been altered to use the ``repoapi`` instead of
    72 the ``dbapi``. Cubes adding new element in this stack are likely to break.
    75 the ``dbapi``. Cubes adding new element to this stack are likely to break.
    73 
    76 
    74 New API in test
       
    75 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    76 
    77 
    77 All current methods and attributes used to access the repo on ``CubicwebTC`` are
    78 New API in tests
    78 deprecated. You can now use a ``RepoAccess`` object. A ``RepoAccess`` object is
    79 ~~~~~~~~~~~~~~~~
       
    80 
       
    81 All current methods and attributes used to access the repo on ``CubicWebTC`` are
       
    82 deprecated. You may now use a ``RepoAccess`` object. A ``RepoAccess`` object is
    79 linked to a new ``Session`` for a specified user. It is able to create
    83 linked to a new ``Session`` for a specified user. It is able to create
    80 ``Connection``, ``ClientConnection`` and web side request linked to this
    84 ``Connection``, ``ClientConnection`` and web side requests linked to this
    81 session::
    85 session::
    82 
    86 
    83     access =self.new_access("babar") # create a new RepoAccess for user babar
    87     access = self.new_access('babar') # create a new RepoAccess for user babar
    84     with access.repo_cnx() as cnx:
    88     with access.repo_cnx() as cnx:
    85         # some work with server side cnx
    89         # some work with server side cnx
    86         cnx.execute(…)
    90         cnx.execute(...)
    87         cnx.commit()
    91         cnx.commit()
    88         cnx.execute(…)
    92         cnx.execute(...)
    89         cnx.commit()
    93         cnx.commit()
    90 
    94 
    91     with access.client_cnx() as cnx:
    95     with access.client_cnx() as cnx:
    92         # some work with client side cnx
    96         # some work with client side cnx
    93         cnx.execute(…)
    97         cnx.execute(...)
    94         cnx.commit()
    98         cnx.commit()
    95 
    99 
    96     with access.web_request(elephant="babar") as req:
   100     with access.web_request(elephant='babar') as req:
    97         # some work with client side cnx
   101         # some work with client side cnx
    98         elephant_name = req.form["elephant"]
   102         elephant_name = req.form['elephant']
    99         req.execute(…)
   103         req.execute(...)
   100         req.cnx.commit()
   104         req.cnx.commit()
   101 
   105 
   102 By default ``testcase.admin_access`` contains a ``RepoAccess`` object for the
   106 By default ``testcase.admin_access`` contains a ``RepoAccess`` object for the
   103 default admin session.
   107 default admin session.
   104 
   108 
   111   request.
   115   request.
   112 
   116 
   113 * ``SessionManager`` and ``AuthenticationManager`` now take a repo object at
   117 * ``SessionManager`` and ``AuthenticationManager`` now take a repo object at
   114   initialization time instead of a vreg.
   118   initialization time instead of a vreg.
   115 
   119 
   116 * The ``async`` argument of ``_cw.call_service`` have been dropped. All call are
   120 * The ``async`` argument of ``_cw.call_service`` has been dropped. All calls are
   117   now  synchronous. The zmq notification bus looks like a good replacement for
   121   now  synchronous. The zmq notification bus looks like a good replacement for
   118   most async usecase.
   122   most async use cases.
   119 
   123 
   120 * ``repo.stats()`` is now deprecated. The same information are available through
   124 * ``repo.stats()`` is now deprecated. The same information is available through
   121   a service (``_cw.call_service('repo_stats')``)
   125   a service (``_cw.call_service('repo_stats')``).
   122 
   126 
   123 * ``repo.gc_stats()`` is now deprecated. The same information are available through
   127 * ``repo.gc_stats()`` is now deprecated. The same information is available through
   124   a service (``_cw.call_service('repo_gc_stats')``)
   128   a service (``_cw.call_service('repo_gc_stats')``).
   125 
   129 
   126 * ``request.set_session`` no longer takes an optional ``user`` argument.
   130 * ``request.set_session`` no longer takes an optional ``user`` argument.
   127 
   131 
   128 * CubicwebTC does not have repo and cnx as class attributes anymore. They are
   132 * CubicwebTC does not have repo and cnx as class attributes anymore. They are
   129   standard instance attributes. ``set_cnx`` and ``_init_repo`` class methods
   133   standard instance attributes. ``set_cnx`` and ``_init_repo`` class methods
   134 
   138 
   135 
   139 
   136 Deprecated Code Drops
   140 Deprecated Code Drops
   137 ----------------------
   141 ----------------------
   138 
   142 
   139 * The ldapuser source has been dropped. ldapfeed is the only official source
       
   140   remaining for ldap.
       
   141 
       
   142 * session.hijack_user mechanism has been dropped.
   143 * session.hijack_user mechanism has been dropped.