fix version number: we still target cw 3.19
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Mon, 13 Jan 2014 15:56:52 +0100
changeset 9404 3e3e9b37e177
parent 9403 d81207fb9499
child 9405 7fc5e13d049f
fix version number: we still target cw 3.19
dbapi.py
devtools/testlib.py
doc/3.19.rst
doc/4.0.rst
repoapi.py
server/repository.py
server/session.py
--- a/dbapi.py	Mon Jan 13 13:56:16 2014 +0100
+++ b/dbapi.py	Mon Jan 13 15:56:52 2014 +0100
@@ -93,7 +93,7 @@
 
 
 
-@deprecated('[4.0] the dbapi is deprecated. Have a look at the new repoapi.')
+@deprecated('[3.19] the dbapi is deprecated. Have a look at the new repoapi.')
 def _repo_connect(repo, login, **kwargs):
     """Constructor to create a new connection to the given CubicWeb repository.
 
--- a/devtools/testlib.py	Mon Jan 13 13:56:16 2014 +0100
+++ b/devtools/testlib.py	Mon Jan 13 15:56:52 2014 +0100
@@ -274,7 +274,7 @@
         while self._open_access:
             self._open_access.pop().close()
 
-    @deprecated('[4.0] explicitly use RepoAccess object in test instead')
+    @deprecated('[3.19] explicitly use RepoAccess object in test instead')
     def set_cnx(self, cnx):
         """"""
         # XXX we want to deprecate this
@@ -287,7 +287,7 @@
             self._current_clt_cnx = cnx
 
     @property
-    @deprecated('[4.0] explicitly use RepoAccess object in test instead')
+    @deprecated('[3.19] explicitly use RepoAccess object in test instead')
     def cnx(self):
         # XXX we want to deprecate this
         clt_cnx = self._current_clt_cnx
@@ -304,7 +304,7 @@
             self._cnxs.remove(cnx)
 
     @property
-    @deprecated('[4.0] explicitly use RepoAccess object in test instead')
+    @deprecated('[3.19] explicitly use RepoAccess object in test instead')
     def session(self):
         """return current server side session"""
         # XXX We want to use a srv_connection instead and deprecate this
@@ -320,17 +320,17 @@
         return session
 
     @property
-    @deprecated('[4.0] explicitly use RepoAccess object in test instead')
+    @deprecated('[3.19] explicitly use RepoAccess object in test instead')
     def websession(self):
         return self.session
 
     @property
-    @deprecated('[4.0] explicitly use RepoAccess object in test instead')
+    @deprecated('[3.19] explicitly use RepoAccess object in test instead')
     def adminsession(self):
         """return current server side session (using default manager account)"""
         return self._admin_session
 
-    @deprecated('[4.0] explicitly use RepoAccess object in test instead')
+    @deprecated('[3.19] explicitly use RepoAccess object in test instead')
     def login(self, login, **kwargs):
         """return a connection for the given login/password"""
         __ = kwargs.pop('autoclose', True) # not used anymore
@@ -345,7 +345,7 @@
         clt_cnx.__enter__()
         return TestCaseConnectionProxy(self, clt_cnx)
 
-    @deprecated('[4.0] explicitly use RepoAccess object in test instead')
+    @deprecated('[3.19] explicitly use RepoAccess object in test instead')
     def restore_connection(self):
         self._pop_custom_cnx()
 
@@ -383,7 +383,7 @@
     # db api ##################################################################
 
     @nocoverage
-    @deprecated('[4.0] explicitly use RepoAccess object in test instead')
+    @deprecated('[3.19] explicitly use RepoAccess object in test instead')
     def cursor(self, req=None):
         if req is not None:
             return req.cnx
@@ -391,7 +391,7 @@
             return self.cnx
 
     @nocoverage
-    @deprecated('[4.0] explicitly use RepoAccess object in test instead')
+    @deprecated('[3.19] explicitly use RepoAccess object in test instead')
     def execute(self, rql, args=None, req=None):
         """executes <rql>, builds a resultset, and returns a couple (rset, req)
         where req is a FakeRequest
@@ -400,7 +400,7 @@
         return req.execute(unicode(rql), args)
 
     @nocoverage
-    @deprecated('[4.0] explicitly use RepoAccess object in test instead')
+    @deprecated('[3.19] explicitly use RepoAccess object in test instead')
     def commit(self):
         try:
             return self.cnx.commit()
@@ -408,7 +408,7 @@
             self.session.set_cnxset() # ensure cnxset still set after commit
 
     @nocoverage
-    @deprecated('[4.0] explicitly use RepoAccess object in test instead')
+    @deprecated('[3.19] explicitly use RepoAccess object in test instead')
     def rollback(self):
         try:
             self.cnx.rollback()
@@ -418,7 +418,7 @@
             self.session.set_cnxset() # ensure cnxset still set after commit
 
     requestcls = fake.FakeRequest
-    @deprecated('[4.0] explicitly use RepoAccess object in test instead')
+    @deprecated('[3.19] explicitly use RepoAccess object in test instead')
     def request(self, rollbackfirst=False, url=None, headers={}, **kwargs):
         """return a web ui request"""
         if rollbackfirst:
@@ -429,7 +429,7 @@
 
     # server side db api #######################################################
 
-    @deprecated('[4.0] explicitly use RepoAccess object in test instead')
+    @deprecated('[3.19] explicitly use RepoAccess object in test instead')
     def sexecute(self, rql, args=None):
         self.session.set_cnxset()
         return self.session.execute(rql, args)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/3.19.rst	Mon Jan 13 15:56:52 2014 +0100
@@ -0,0 +1,142 @@
+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.
+Integrity hooks are enabled.
+
+Backward compact is preserved on Session. They can still be used to access the
+database for the next few version.
+
+dbapi vs repoapi
+~~~~~~~~~~~~~~~~
+
+A new API have been introduced to replace the dbapi. It is called "repoapi".
+
+there is three relevant function for now:
+
+``repoapi.get_repository(config)`` takes a config object and return credential
+
+``repoapi.connect(repo, **credential)`` return a ClientConnection associated to
+the user identified by the credential. The ClientConnection is associated to its
+own Session that is closed when the ClientConnection is closed. A
+ClientConnection is a Connection-like object to be used client side.
+
+``repoapi.anonymous_cnx(repo)`` return a ClientConnection associated to the
+anonymous user if describe in the Config.
+
+repoapi.ClientConnection replace dbapi.Connection and company
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+On the client/web side, the Request is now using a ``repoapi.ClientConnection``
+instead of a ``dbapi.connection``. The ``ClientConnection`` have multiple backward
+compat method to looks like a ``dbapi.Cursor`` and ``dbapi.Connection``. It will
+remain that way for a few version.
+
+Session used on the Web side are now the same than the one used Server side.
+Some backward compat method have been installed on the server side Session to
+ease the transition.
+
+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
+-----------
+
+* ``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.
+
+* ``set_cnxset`` and ``free_cnxset`` are deprecated. cnxset are now
+  automatically managed.
+
+
+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.
--- a/doc/4.0.rst	Mon Jan 13 13:56:16 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-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.
-Integrity hooks are enabled.
-
-Backward compact is preserved on Session. They can still be used to access the
-database for the next few version.
-
-dbapi vs repoapi
-~~~~~~~~~~~~~~~~
-
-A new API have been introduced to replace the dbapi. It is called "repoapi".
-
-there is three relevant function for now:
-
-``repoapi.get_repository(config)`` takes a config object and return credential
-
-``repoapi.connect(repo, **credential)`` return a ClientConnection associated to
-the user identified by the credential. The ClientConnection is associated to its
-own Session that is closed when the ClientConnection is closed. A
-ClientConnection is a Connection-like object to be used client side.
-
-``repoapi.anonymous_cnx(repo)`` return a ClientConnection associated to the
-anonymous user if describe in the Config.
-
-repoapi.ClientConnection replace dbapi.Connection and company
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-On the client/web side, the Request is now using a ``repoapi.ClientConnection``
-instead of a ``dbapi.connection``. The ``ClientConnection`` have multiple backward
-compat method to looks like a ``dbapi.Cursor`` and ``dbapi.Connection``. It will
-remain that way for a few version.
-
-Session used on the Web side are now the same than the one used Server side.
-Some backward compat method have been installed on the server side Session to
-ease the transition.
-
-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
------------
-
-* ``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.
-
-* ``set_cnxset`` and ``free_cnxset`` are deprecated. cnxset are now
-  automatically managed.
-
-
-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.
--- a/repoapi.py	Mon Jan 13 13:56:16 2014 +0100
+++ b/repoapi.py	Mon Jan 13 15:56:52 2014 +0100
@@ -333,25 +333,25 @@
         # Connection object
         return self._cnx.repo.system_source.undo_transaction(self._cnx, txuuid)
 
-    @deprecated('[4.0] This is a repoapi.ClientConnection object not a dbapi one')
+    @deprecated('[3.19] This is a repoapi.ClientConnection object not a dbapi one')
     def request(self):
         return self
 
-    @deprecated('[4.0] This is a repoapi.ClientConnection object not a dbapi one')
+    @deprecated('[3.19] This is a repoapi.ClientConnection object not a dbapi one')
     def cursor(self):
         return self
 
     @ property
-    @deprecated('[4.0] This is a repoapi.ClientConnection object not a dbapi one')
+    @deprecated('[3.19] This is a repoapi.ClientConnection object not a dbapi one')
     def sessionid(self):
         return self._session.id
 
     @property
-    @deprecated('[4.0] This is a repoapi.ClientConnection object not a dbapi one')
+    @deprecated('[3.19] This is a repoapi.ClientConnection object not a dbapi one')
     def connection(self):
         return self
 
     @property
-    @deprecated('[4.0] This is a repoapi.ClientConnection object not a dbapi one')
+    @deprecated('[3.19] This is a repoapi.ClientConnection object not a dbapi one')
     def _repo(self):
         return self._session.repo
--- a/server/repository.py	Mon Jan 13 13:56:16 2014 +0100
+++ b/server/repository.py	Mon Jan 13 15:56:52 2014 +0100
@@ -516,7 +516,7 @@
 
     # public (dbapi) interface ################################################
 
-    @deprecated("[4.0] use _cw.call_service('repo_stats'")
+    @deprecated("[3.19] use _cw.call_service('repo_stats'")
     def stats(self): # XXX restrict to managers session?
         """Return a dictionary containing some statistics about the repository
         resources usage.
@@ -528,7 +528,7 @@
         with self.internal_session() as session:
             return session.call_service('repo_stats')
 
-    @deprecated("[4.0] use _cw.call_service('repo_gc_stats'")
+    @deprecated("[3.19] use _cw.call_service('repo_gc_stats'")
     def gc_stats(self, nmax=20):
         """Return a dictionary containing some statistics about the repository
         memory usage.
@@ -939,7 +939,7 @@
                 nbclosed += 1
         return nbclosed
 
-    @deprecated("[4.0] use internal_cnx now\n"
+    @deprecated("[3.19] use internal_cnx now\n"
                 "(Beware that integrity hook are now enabled by default)")
     def internal_session(self, cnxprops=None, safe=False):
         """return a dbapi like connection/cursor using internal user which have
--- a/server/session.py	Mon Jan 13 13:56:16 2014 +0100
+++ b/server/session.py	Mon Jan 13 15:56:52 2014 +0100
@@ -628,13 +628,13 @@
                 cnxset.cnxset_freed()
                 self.repo._free_cnxset(cnxset)
 
-    @deprecated('[4.0] cnxset are automatically managed now.'
+    @deprecated('[3.19] cnxset are automatically managed now.'
                 ' stop using explicit set and free.')
     def set_cnxset(self):
         self._auto_free_cnx_set = False
         return self._set_cnxset()
 
-    @deprecated('[4.0] cnxset are automatically managed now.'
+    @deprecated('[3.19] cnxset are automatically managed now.'
                 ' stop using explicit set and free.')
     def free_cnxset(self, ignoremode=False):
         self._auto_free_cnx_set = True
@@ -1188,12 +1188,12 @@
 
     This is to be used by session"""
     args = {}
-    @deprecated('[4.0] use a Connection object instead')
+    @deprecated('[3.19] use a Connection object instead')
     def attr_from_cnx(session):
         return getattr(session._cnx, attr_name)
     args['fget'] = attr_from_cnx
     if writable:
-        @deprecated('[4.0] use a Connection object instead')
+        @deprecated('[3.19] use a Connection object instead')
         def write_attr(session, value):
             return setattr(session._cnx, attr_name, value)
         args['fset'] = write_attr
@@ -1203,7 +1203,7 @@
     """return a function forwarding calls to connection.
 
     This is to be used by session"""
-    @deprecated('[4.0] use a Connection object instead')
+    @deprecated('[3.19] use a Connection object instead')
     def meth_from_cnx(session, *args, **kwargs):
         result = getattr(session._cnx, meth_name)(*args, **kwargs)
         if getattr(result, '_cw', None) is not None:
@@ -1372,7 +1372,7 @@
         return float(self._timestamp)
 
     @property
-    @deprecated('[4.0] session.id is deprecated. use session.sessionid')
+    @deprecated('[3.19] session.id is deprecated. use session.sessionid')
     def id(self):
         return self.sessionid
 
@@ -1436,11 +1436,11 @@
             self.set_cnx()
             return self.__threaddata.cnx
 
-    @deprecated('[4.0] use a Connection object instead')
+    @deprecated('[3.19] use a Connection object instead')
     def get_option_value(self, option, foreid=None):
         return self.repo.get_option_value(option, foreid)
 
-    @deprecated('[4.0] use a Connection object instead')
+    @deprecated('[3.19] use a Connection object instead')
     def transaction(self, free_cnxset=True):
         """return context manager to enter a transaction for the session: when
         exiting the `with` block on exception, call `session.rollback()`, else
@@ -1469,7 +1469,7 @@
 
     # security control #########################################################
 
-    @deprecated('[4.0] use a Connection object instead')
+    @deprecated('[3.19] use a Connection object instead')
     def security_enabled(self, read=None, write=None):
         return _session_security_enabled(self, read=read, write=write)
 
@@ -1481,10 +1481,10 @@
     # all hooks should be activated during normal execution
 
 
-    @deprecated('[4.0] use a Connection object instead')
+    @deprecated('[3.19] use a Connection object instead')
     def allow_all_hooks_but(self, *categories):
         return _session_hooks_control(self, HOOKS_ALLOW_ALL, *categories)
-    @deprecated('[4.0] use a Connection object instead')
+    @deprecated('[3.19] use a Connection object instead')
     def deny_all_hooks_but(self, *categories):
         return _session_hooks_control(self, HOOKS_DENY_ALL, *categories)
 
@@ -1499,7 +1499,7 @@
 
     # connection management ###################################################
 
-    @deprecated('[4.0] use a Connection object instead')
+    @deprecated('[3.19] use a Connection object instead')
     def keep_cnxset_mode(self, mode):
         """set `mode`, e.g. how the session will keep its connections set:
 
@@ -1524,7 +1524,7 @@
     commit_state = cnx_attr('commit_state', writable=True)
 
     @property
-    @deprecated('[4.0] use a Connection object instead')
+    @deprecated('[3.19] use a Connection object instead')
     def cnxset(self):
         """connections set, set according to transaction mode for each query"""
         if self._closed:
@@ -1580,7 +1580,7 @@
     # request interface #######################################################
 
     @property
-    @deprecated('[4.0] use a Connection object instead')
+    @deprecated('[3.19] use a Connection object instead')
     def cursor(self):
         """return a rql cursor"""
         return self
@@ -1595,7 +1595,7 @@
     source_from_eid = cnx_meth('source_from_eid')
 
 
-    @deprecated('[4.0] use a Connection object instead')
+    @deprecated('[3.19] use a Connection object instead')
     def execute(self, *args, **kwargs):
         """db-api like method directly linked to the querier execute method.
 
@@ -1624,7 +1624,7 @@
             else:
                 cnx.clear()
 
-    @deprecated('[4.0] use a Connection object instead')
+    @deprecated('[3.19] use a Connection object instead')
     def commit(self, free_cnxset=True, reset_pool=None):
         """commit the current session's transaction"""
         cstate = self._cnx.commit_state
@@ -1635,7 +1635,7 @@
         finally:
             self._clear_thread_data(free_cnxset)
 
-    @deprecated('[4.0] use a Connection object instead')
+    @deprecated('[3.19] use a Connection object instead')
     def rollback(self, free_cnxset=True, **kwargs):
         """rollback the current session's transaction"""
         try:
@@ -1700,7 +1700,7 @@
     # deprecated ###############################################################
 
     @property
-    @deprecated('[4.0] use a Connection object instead')
+    @deprecated('[3.19] use a Connection object instead')
     def anonymous_session(self):
         # XXX for now, anonymous-user is a web side option.
         # It will only be present inside all-in-one instance.