[reload] on registry reloading, we should change class of users of opened session stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 30 Mar 2010 13:29:55 +0200
branchstable
changeset 5079 e646047f80cb
parent 5078 ea66c4aabb47
child 5080 cfc7c2b24f9e
[reload] on registry reloading, we should change class of users of opened session
server/repository.py
--- a/server/repository.py	Tue Mar 30 13:28:19 2010 +0200
+++ b/server/repository.py	Tue Mar 30 13:29:55 2010 +0200
@@ -38,10 +38,11 @@
                       UnknownEid, AuthenticationError, ExecutionError,
                       ETypeNotSupportedBySources, MultiSourcesError,
                       BadConnectionId, Unauthorized, ValidationError,
-                      typed_eid)
+                      typed_eid, onevent)
 from cubicweb import cwvreg, schema, server
 from cubicweb.server import utils, hook, pool, querier, sources
-from cubicweb.server.session import Session, InternalSession, security_enabled
+from cubicweb.server.session import Session, InternalSession, InternalManager, \
+     security_enabled
 
 
 def del_existing_rel_if_needed(session, eidfrom, rtype, eidto):
@@ -132,6 +133,12 @@
         # open some connections pools
         if config.open_connections_pools:
             self.open_connections_pools()
+        @onevent('after-registry-reload', self)
+        def fix_user_classes(self):
+            usercls = self.vreg['etypes'].etype_class('CWUser')
+            for session in self._sessions.values():
+                if not isinstance(session.user, InternalManager):
+                    session.user.__class__ = usercls
 
     def _bootstrap_hook_registry(self):
         """called during bootstrap since we need the metadata hooks"""