server/repository.py
branchstable
changeset 5079 e646047f80cb
parent 5073 a9697325cffa
child 5084 d8f491cb046c
equal deleted inserted replaced
5078:ea66c4aabb47 5079:e646047f80cb
    36 
    36 
    37 from cubicweb import (CW_SOFTWARE_ROOT, CW_MIGRATION_MAP,
    37 from cubicweb import (CW_SOFTWARE_ROOT, CW_MIGRATION_MAP,
    38                       UnknownEid, AuthenticationError, ExecutionError,
    38                       UnknownEid, AuthenticationError, ExecutionError,
    39                       ETypeNotSupportedBySources, MultiSourcesError,
    39                       ETypeNotSupportedBySources, MultiSourcesError,
    40                       BadConnectionId, Unauthorized, ValidationError,
    40                       BadConnectionId, Unauthorized, ValidationError,
    41                       typed_eid)
    41                       typed_eid, onevent)
    42 from cubicweb import cwvreg, schema, server
    42 from cubicweb import cwvreg, schema, server
    43 from cubicweb.server import utils, hook, pool, querier, sources
    43 from cubicweb.server import utils, hook, pool, querier, sources
    44 from cubicweb.server.session import Session, InternalSession, security_enabled
    44 from cubicweb.server.session import Session, InternalSession, InternalManager, \
       
    45      security_enabled
    45 
    46 
    46 
    47 
    47 def del_existing_rel_if_needed(session, eidfrom, rtype, eidto):
    48 def del_existing_rel_if_needed(session, eidfrom, rtype, eidto):
    48     """delete existing relation when adding a new one if card is 1 or ?
    49     """delete existing relation when adding a new one if card is 1 or ?
    49 
    50 
   130         # cache (extid, source uri) -> eid
   131         # cache (extid, source uri) -> eid
   131         self._extid_cache = {}
   132         self._extid_cache = {}
   132         # open some connections pools
   133         # open some connections pools
   133         if config.open_connections_pools:
   134         if config.open_connections_pools:
   134             self.open_connections_pools()
   135             self.open_connections_pools()
       
   136         @onevent('after-registry-reload', self)
       
   137         def fix_user_classes(self):
       
   138             usercls = self.vreg['etypes'].etype_class('CWUser')
       
   139             for session in self._sessions.values():
       
   140                 if not isinstance(session.user, InternalManager):
       
   141                     session.user.__class__ = usercls
   135 
   142 
   136     def _bootstrap_hook_registry(self):
   143     def _bootstrap_hook_registry(self):
   137         """called during bootstrap since we need the metadata hooks"""
   144         """called during bootstrap since we need the metadata hooks"""
   138         hooksdirectory = join(CW_SOFTWARE_ROOT, 'hooks')
   145         hooksdirectory = join(CW_SOFTWARE_ROOT, 'hooks')
   139         self.vreg.init_registration([hooksdirectory])
   146         self.vreg.init_registration([hooksdirectory])