cubicweb/server/repository.py
changeset 12025 ba79f4a4f5d8
parent 12021 cc8135ecfbb8
child 12027 c62c80f20a82
equal deleted inserted replaced
12024:5f46195b9595 12025:ba79f4a4f5d8
    43 from rql.utils import rqlvar_maker
    43 from rql.utils import rqlvar_maker
    44 
    44 
    45 from cubicweb import (CW_MIGRATION_MAP, QueryError,
    45 from cubicweb import (CW_MIGRATION_MAP, QueryError,
    46                       UnknownEid, AuthenticationError, ExecutionError,
    46                       UnknownEid, AuthenticationError, ExecutionError,
    47                       BadConnectionId,
    47                       BadConnectionId,
    48                       UniqueTogetherError, onevent, ViolatedConstraint)
    48                       UniqueTogetherError, ViolatedConstraint)
    49 from cubicweb import set_log_methods
    49 from cubicweb import set_log_methods
    50 from cubicweb import cwvreg, schema, server
    50 from cubicweb import cwvreg, schema, server
    51 from cubicweb.server import utils, hook, querier, sources
    51 from cubicweb.server import utils, hook, querier, sources
    52 from cubicweb.server.session import Session, InternalManager
    52 from cubicweb.server.session import Session, InternalManager
    53 
    53 
   239         self.querier = querier.QuerierHelper(self, self.schema)
   239         self.querier = querier.QuerierHelper(self, self.schema)
   240         # cache eid -> type
   240         # cache eid -> type
   241         self._type_cache = {}
   241         self._type_cache = {}
   242         # the hooks manager
   242         # the hooks manager
   243         self.hm = hook.HooksManager(self.vreg)
   243         self.hm = hook.HooksManager(self.vreg)
   244 
       
   245         # registry hook to fix user class on registry reload
       
   246         @onevent('after-registry-reload', self)
       
   247         def fix_user_classes(self):
       
   248             # After registry reload the 'CWUser' class used for CWEtype
       
   249             # changed.  So any existing user object have a different class than
       
   250             # the new loaded one. We are hot fixing this.
       
   251             usercls = self.vreg['etypes'].etype_class('CWUser')
       
   252             for session in self._sessions.values():
       
   253                 if not isinstance(session.user, InternalManager):
       
   254                     session.user.__class__ = usercls
       
   255 
   244 
   256     def bootstrap(self):
   245     def bootstrap(self):
   257         self.info('starting repository from %s', self.config.apphome)
   246         self.info('starting repository from %s', self.config.apphome)
   258         self.shutting_down = False
   247         self.shutting_down = False
   259         config = self.config
   248         config = self.config