[request] drop the user argument for set_session
I see no code nor test that use this optional argument. removing it help to
clean the session code. The set_session function will soon be deprecated anyway (at the
same time than the dbapi)
related to #2503918
--- a/dbapi.py Wed Jun 19 12:00:54 2013 +0200
+++ b/dbapi.py Mon Jun 24 12:39:25 2013 +0200
@@ -334,7 +334,7 @@
def get_option_value(self, option, foreid=None):
return self.cnx.get_option_value(option, foreid)
- def set_session(self, session, user=None):
+ def set_session(self, session):
"""method called by the session handler when the user is authenticated
or an anonymous connection is open
"""
@@ -342,11 +342,8 @@
if session.cnx:
self.cnx = session.cnx
self.execute = session.cnx.cursor(self).execute
- if user is None:
- user = self.cnx.user(self)
- if user is not None:
- self.user = user
- self.set_entity_cache(user)
+ self.user = self.cnx.user(self)
+ self.set_entity_cache(self.user)
def execute(self, *args, **kwargs): # pylint: disable=E0202
"""overriden when session is set. By default raise authentication error
@@ -657,8 +654,8 @@
from cubicweb.web.request import CubicWebRequestBase
req = CubicWebRequestBase(self.vreg, False)
req.get_header = lambda x, default=None: default
- req.set_session = lambda session, user=None: DBAPIRequest.set_session(
- req, session, user)
+ req.set_session = lambda session: DBAPIRequest.set_session(
+ req, session)
req.relative_path = lambda includeparams=True: ''
else:
req = DBAPIRequest(self.vreg)
--- a/doc/4.0.rst Wed Jun 19 12:00:54 2013 +0200
+++ b/doc/4.0.rst Mon Jun 24 12:39:25 2013 +0200
@@ -21,6 +21,8 @@
* ``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.
+
Deprecated Code Drops
----------------------
--- a/web/request.py Wed Jun 19 12:00:54 2013 +0200
+++ b/web/request.py Mon Jun 24 12:39:25 2013 +0200
@@ -219,11 +219,11 @@
self.set_page_data('rql_varmaker', varmaker)
return varmaker
- def set_session(self, session, user=None):
+ def set_session(self, session):
"""method called by the session handler when the user is authenticated
or an anonymous connection is open
"""
- super(CubicWebRequestBase, self).set_session(session, user)
+ super(CubicWebRequestBase, self).set_session(session)
# set request language
vreg = self.vreg
if self.user: