[webrequest] set DBAPISession without cnx at initialisation time
Such session are necessary for minimal use of a Request. Setting on by default
allow simplification later linking with a full featured DBAPISession or
equivalent. This was not possible before as all session was tracked by session
manager. They are not tracked anymore since aa709bc6b6c1 and we can safely
create them by default.
related to #2503918
--- a/dbapi.py Mon Jun 24 12:41:27 2013 +0200
+++ b/dbapi.py Fri Jun 21 16:28:16 2013 +0200
@@ -327,7 +327,7 @@
else:
# these args are initialized after a connection is
# established
- self.session = None
+ self.session = DBAPISession(None)
self.cnx = self.user = _NeedAuthAccessMock()
self.set_default_language(vreg)
--- a/web/application.py Mon Jun 24 12:41:27 2013 +0200
+++ b/web/application.py Fri Jun 21 16:28:16 2013 +0200
@@ -340,10 +340,14 @@
session = self.get_session(req)
req.set_session(session)
except AuthenticationError:
+ # Keep the dummy session set at initialisation.
+ # such session with work to an some extend but raise an
+ # AuthenticationError on any database access.
+ pass
# XXX We want to clean up this approach in the future. But
# several cubes like registration or forgotten password rely on
# this principle.
- req.set_session(DBAPISession(None))
+ assert req.session is not None
# DENY https acces for anonymous_user
if (req.https
and req.session.anonymous_session