doc/4.0.rst
author Pierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 27 Jun 2013 12:28:17 +0200
changeset 9114 9a9d3f4bad31
parent 9113 af6efc15fc90
child 9115 fcc732a9d9ac
permissions -rw-r--r--
[testlib] use internal_cnx instead of internal_session internal_session is deprecated.

What's new in CubicWeb 4.0?
============================

Behavior Changes
----------------

* The anonymous property of Session and Connection are now computed from the
  related user login. If it match the ``anonymous-user`` in the config the
  connection is anonymous. Beware that the ``anonymous-user`` config is web
  specific. Therefore, no session may be anonymous in repository only setup.

New Repository Access API
-------------------------

Connection replace Session
~~~~~~~~~~~~~~~~~~~~~~~~~~

A new explicite Connection object replace Session as the main repository entry
point. Connection hold all the necessary methods to be used Server side
(``execute``, ``commit``, ``rollback``, ``call_service``, ``entity_from_eid``,
etc…). You obtains a new Connection object using ``session.new_cnx()``.
Connection object need have an explicite begin and end. Use them as a context
manager::

    with session.new_cnx() as cnx:
        self.execute('INSERT Elephant E, E name "Cabar"')
        self.commit()
        self.execute('INSERT Elephant E, E name "Celeste"')
        self.commit()
    # Once you get out of the "with" clause, the connection is closed.

Using the same Connection object in multiple threads will give you access to the
same Transaction. However, Connection object are not thread safe.

``repository.internal_session`` is deprecated in favor of
``repository.internal_cnx``. Note that internal connection are now safe by
default. Integrity hooks are enabled except stated otherwise.

Backward compact is preserved on Session. They can still be used to access the
database for the next few version.


API changes
-----------

* ``RepositorySessionManager.postlogin`` is now called with two arguments,
  request and session. And this now happens before the session is linked to the
  request.

* ``SessionManager`` and ``AuthenticationManager`` now take a repo object at
  initialization time instead of a vreg.

* The ``async`` argument of ``_cw.call_service`` have been dropped. All call are
  now  synchronous. The zmq notification bus looks like a good replacement for
  most async usecase.

* ``repo.stats()`` is now deprecated. The same information are available through
  a service (``_cw.call_service('repo_stats')``)

* ``repo.gc_stats()`` is now deprecated. The same information are available through
  a service (``_cw.call_service('repo_gc_stats')``)

* ``request.set_session`` no longer takes an optional ``user`` argument.

* CubicwebTC does not have repo and cnx as class attributes anymore. They are
  standard instance attributes. ``set_cnx`` and ``_init_repo`` class methods
  become instance methods.


Deprecated Code Drops
----------------------

* The ldapuser source has been dropped. ldapfeed is the only official source
  remaining for ldap.

* session.hijack_user mechanism has been dropped.