--- a/cwvreg.py Tue Aug 04 18:43:55 2009 +0200
+++ b/cwvreg.py Tue Aug 04 18:44:24 2009 +0200
@@ -16,7 +16,7 @@
from cubicweb import (ETYPE_NAME_MAP, Binary, UnknownProperty, UnknownEid,
ObjectNotFound, NoSelectableObject, RegistryNotFound,
- RegistryOutOfDate)
+ RegistryOutOfDate, CW_EVENT_MANAGER)
from cubicweb.utils import dump_class
from cubicweb.vregistry import VRegistry, Registry
from cubicweb.rtags import RTAGS
@@ -305,10 +305,12 @@
try:
self._register_objects(path, force_reload)
except RegistryOutOfDate:
+ CW_EVENT_MANAGER.emit('before-source-reload')
# modification detected, reset and reload
self.reset()
cleanup_sys_modules(path)
self._register_objects(path, force_reload)
+ CW_EVENT_MANAGER.emit('after-source-reload')
def _register_objects(self, path, force_reload=None):
"""overriden to remove objects requiring a missing interface"""
--- a/etwist/server.py Tue Aug 04 18:43:55 2009 +0200
+++ b/etwist/server.py Tue Aug 04 18:44:24 2009 +0200
@@ -22,10 +22,10 @@
from twisted.web2 import channel, http, server, iweb
from twisted.web2 import static, resource, responsecode
-from cubicweb import ObjectNotFound
+from cubicweb import ObjectNotFound, CW_EVENT_MANAGER
from cubicweb.web import (AuthenticationError, NotFound, Redirect,
- RemoteCallFailed, DirectResponse, StatusResponse,
- ExplicitLogin)
+ RemoteCallFailed, DirectResponse, StatusResponse,
+ ExplicitLogin)
from cubicweb.web.application import CubicWebPublisher
from cubicweb.etwist.request import CubicWebTwistedRequestAdapter
@@ -109,11 +109,15 @@
self.pyro_listen_timeout = 0.02
start_task(1, self.pyro_loop_event)
self.appli.repo.start_looping_tasks()
- self.url_rewriter = self.appli.vreg['components'].select_object('urlrewriter')
+ self.set_url_rewriter()
+ CW_EVENT_MANAGER.bind('after-source-reload', self.set_url_rewriter)
interval = min(config['cleanup-session-time'] or 120,
config['cleanup-anonymous-session-time'] or 720) / 2.
start_task(interval, self.appli.session_handler.clean_sessions)
+ def set_url_rewriter(self):
+ self.url_rewriter = self.appli.vreg['components'].select_object('urlrewriter')
+
def shutdown_event(self):
"""callback fired when the server is shutting down to properly
clean opened sessions
--- a/web/application.py Tue Aug 04 18:43:55 2009 +0200
+++ b/web/application.py Tue Aug 04 18:44:24 2009 +0200
@@ -17,7 +17,7 @@
from cubicweb import set_log_methods, cwvreg
from cubicweb import (
ValidationError, Unauthorized, AuthenticationError, NoSelectableObject,
- RepositoryError)
+ RepositoryError, CW_EVENT_MANAGER)
from cubicweb.web import LOGGER, component
from cubicweb.web import (
StatusResponse, DirectResponse, Redirect, NotFound,
@@ -41,6 +41,10 @@
if self.session_time:
assert self.cleanup_session_time < self.session_time
assert self.cleanup_anon_session_time < self.session_time
+ self.set_authmanager()
+ CW_EVENT_MANAGER.bind('after-source-reload', self.set_authmanager)
+
+ def set_authmanager(self):
self.authmanager = self.vreg['components'].select('authmanager')
def clean_sessions(self):
@@ -239,7 +243,11 @@
self.publish = self.main_publish
# instantiate session and url resolving helpers
self.session_handler = session_handler_fact(self)
- self.url_resolver = vreg['components'].select('urlpublisher')
+ self.set_urlresolver()
+ CW_EVENT_MANAGER.bind('after-source-reload', self.set_urlresolver)
+
+ def set_urlresolver(self):
+ self.url_resolver = self.vreg['components'].select('urlpublisher')
def connect(self, req):
"""return a connection for a logged user object according to existing