--- a/goa/appobjects/sessions.py Mon Aug 17 19:21:26 2009 +0200
+++ b/goa/appobjects/sessions.py Mon Aug 17 19:21:45 2009 +0200
@@ -73,9 +73,9 @@
class GAEPersistentSessionManager(AbstractSessionManager):
"""manage session data associated to a session identifier"""
- def __init__(self, *args, **kwargs):
- super(GAEPersistentSessionManager, self).__init__(*args, **kwargs)
- self._repo = self.config.repository(vreg=self.vreg)
+ def __init__(self, vreg, *args, **kwargs):
+ super(GAEPersistentSessionManager, self).__init__(vreg, *args, **kwargs)
+ self._repo = self.config.repository(vreg=vreg)
def get_session(self, req, sessionid):
"""return existing session for the given session identifier"""
--- a/web/application.py Mon Aug 17 19:21:26 2009 +0200
+++ b/web/application.py Mon Aug 17 19:21:45 2009 +0200
@@ -31,17 +31,17 @@
"""manage session data associated to a session identifier"""
id = 'sessionmanager'
- def __init__(self):
- self.session_time = self.vreg.config['http-session-time'] or None
+ def __init__(self, vreg):
+ self.session_time = vreg.config['http-session-time'] or None
assert self.session_time is None or self.session_time > 0
- self.cleanup_session_time = self.vreg.config['cleanup-session-time'] or 43200
+ self.cleanup_session_time = vreg.config['cleanup-session-time'] or 43200
assert self.cleanup_session_time > 0
- self.cleanup_anon_session_time = self.vreg.config['cleanup-anonymous-session-time'] or 120
+ self.cleanup_anon_session_time = vreg.config['cleanup-anonymous-session-time'] or 120
assert self.cleanup_anon_session_time > 0
if self.session_time:
assert self.cleanup_session_time < self.session_time
assert self.cleanup_anon_session_time < self.session_time
- self.authmanager = self.vreg['components'].select('authmanager')
+ self.authmanager = vreg['components'].select('authmanager', vreg=vreg)
def clean_sessions(self):
"""cleanup sessions which has not been unused since a given amount of
@@ -92,6 +92,10 @@
class AbstractAuthenticationManager(component.Component):
"""authenticate user associated to a request and check session validity"""
id = 'authmanager'
+ vreg = None # XXX necessary until property for deprecation warning is on appobject
+
+ def __init__(self, vreg):
+ self.vreg = vreg
def authenticate(self, req):
"""authenticate user and return corresponding user object
@@ -113,7 +117,8 @@
def __init__(self, appli):
self.vreg = appli.vreg
- self.session_manager = self.vreg['components'].select('sessionmanager')
+ self.session_manager = self.vreg['components'].select('sessionmanager',
+ vreg=self.vreg)
global SESSION_MANAGER
SESSION_MANAGER = self.session_manager
if not 'last_login_time' in self.vreg.schema:
@@ -122,7 +127,8 @@
def reset_session_manager(self):
data = self.session_manager.dump_data()
- self.session_manager = self.vreg['components'].select('sessionmanager')
+ self.session_manager = self.vreg['components'].select('sessionmanager',
+ vreg=self.vreg)
self.session_manager.restore_data(data)
global SESSION_MANAGER
SESSION_MANAGER = self.session_manager
@@ -252,7 +258,8 @@
CW_EVENT_MANAGER.bind('after-registry-reload', self.set_urlresolver)
def set_urlresolver(self):
- self.url_resolver = self.vreg['components'].select('urlpublisher')
+ self.url_resolver = self.vreg['components'].select('urlpublisher',
+ vreg=self.vreg)
def connect(self, req):
"""return a connection for a logged user object according to existing
--- a/web/views/authentication.py Mon Aug 17 19:21:26 2009 +0200
+++ b/web/views/authentication.py Mon Aug 17 19:21:45 2009 +0200
@@ -18,9 +18,10 @@
class RepositoryAuthenticationManager(AbstractAuthenticationManager):
"""authenticate user associated to a request and check session validity"""
- def __init__(self):
- self.repo = self.config.repository(self.vreg)
- self.log_queries = self.config['query-log-file']
+ def __init__(self, vreg):
+ super(RepositoryAuthenticationManager, self).__init__(vreg)
+ self.repo = vreg.config.repository(vreg)
+ self.log_queries = vreg.config['query-log-file']
def validate_session(self, req, session):
"""check session validity, and return eventually hijacked session
--- a/web/views/sessions.py Mon Aug 17 19:21:26 2009 +0200
+++ b/web/views/sessions.py Mon Aug 17 19:21:45 2009 +0200
@@ -15,8 +15,8 @@
class InMemoryRepositorySessionManager(AbstractSessionManager):
"""manage session data associated to a session identifier"""
- def __init__(self):
- AbstractSessionManager.__init__(self)
+ def __init__(self, *args, **kwargs):
+ AbstractSessionManager.__init__(self, *args, **kwargs)
# XXX require a RepositoryAuthenticationManager which violates
# authenticate interface by returning a session instead of a user
#assert isinstance(self.authmanager, RepositoryAuthenticationManager)
--- a/web/views/urlpublishing.py Mon Aug 17 19:21:26 2009 +0200
+++ b/web/views/urlpublishing.py Mon Aug 17 19:21:45 2009 +0200
@@ -28,8 +28,7 @@
from rql import TypeResolverException
from cubicweb import RegistryException, typed_eid
-from cubicweb.web import NotFound, Redirect
-from cubicweb.web.component import Component, Component
+from cubicweb.web import NotFound, Redirect, component
class PathDontMatch(Exception):
@@ -37,7 +36,7 @@
a path
"""
-class URLPublisherComponent(Component):
+class URLPublisherComponent(component.Component):
"""associate url's path to view identifier / rql queries,
by applying a chain of urlpathevaluator components.
@@ -51,12 +50,14 @@
something else than `PathDontMatch` will stop the handlers chain.
"""
id = 'urlpublisher'
+ vreg = None # XXX necessary until property for deprecation warning is on appobject
- def __init__(self, default_method='view'):
+ def __init__(self, vreg, default_method='view'):
super(URLPublisherComponent, self).__init__()
+ self.vreg = vreg
self.default_method = default_method
evaluators = []
- for evaluatorcls in self.vreg['components']['urlpathevaluator']:
+ for evaluatorcls in vreg['components']['urlpathevaluator']:
# instantiation needed
evaluator = evaluatorcls(self)
evaluators.append(evaluator)
@@ -98,13 +99,14 @@
return pmid, rset
-class URLPathEvaluator(Component):
+class URLPathEvaluator(component.Component):
__abstract__ = True
id = 'urlpathevaluator'
+ vreg = None # XXX necessary until property for deprecation warning is on appobject
def __init__(self, urlpublisher):
self.urlpublisher = urlpublisher
-
+ self.vreg = urlpublisher.vreg
class RawPathEvaluator(URLPathEvaluator):
"""handle path of the form::