server/repository.py
changeset 2709 6ee816eb9f25
parent 2708 60d728bdcba5
child 2731 815b93271338
equal deleted inserted replaced
2708:60d728bdcba5 2709:6ee816eb9f25
    26 from logilab.common.decorators import cached
    26 from logilab.common.decorators import cached
    27 
    27 
    28 from yams import BadSchemaDefinition
    28 from yams import BadSchemaDefinition
    29 from rql import RQLSyntaxError
    29 from rql import RQLSyntaxError
    30 
    30 
    31 from cubicweb import (CW_SOFTWARE_ROOT, UnknownEid, AuthenticationError,
    31 from cubicweb import (CW_SOFTWARE_ROOT, CW_MIGRATION_MAP, CW_EVENT_MANAGER,
       
    32                       UnknownEid, AuthenticationError, ExecutionError,
    32                       ETypeNotSupportedBySources, RTypeNotSupportedBySources,
    33                       ETypeNotSupportedBySources, RTypeNotSupportedBySources,
    33                       BadConnectionId, Unauthorized, ValidationError,
    34                       BadConnectionId, Unauthorized, ValidationError,
    34                       ExecutionError, typed_eid,
    35                       typed_eid)
    35                       CW_MIGRATION_MAP)
       
    36 from cubicweb.cwvreg import CubicWebVRegistry
    36 from cubicweb.cwvreg import CubicWebVRegistry
    37 from cubicweb.schema import VIRTUAL_RTYPES, CubicWebSchema
    37 from cubicweb.schema import VIRTUAL_RTYPES, CubicWebSchema
    38 from cubicweb import server
    38 from cubicweb import server
    39 from cubicweb.server.utils import RepoThread, LoopTask
    39 from cubicweb.server.utils import RepoThread, LoopTask
    40 from cubicweb.server.pool import ConnectionsPool, LateOperation, SingleLastOperation
    40 from cubicweb.server.pool import ConnectionsPool, LateOperation, SingleLastOperation
   226             # call instance level initialisation hooks
   226             # call instance level initialisation hooks
   227             self.hm.call_hooks('server_startup', repo=self)
   227             self.hm.call_hooks('server_startup', repo=self)
   228             # register a task to cleanup expired session
   228             # register a task to cleanup expired session
   229             self.looping_task(self.config['session-time']/3.,
   229             self.looping_task(self.config['session-time']/3.,
   230                               self.clean_sessions)
   230                               self.clean_sessions)
       
   231         CW_EVENT_MANAGER.bind('after-registry-load', self.reset_hooks)
   231 
   232 
   232     # internals ###############################################################
   233     # internals ###############################################################
   233 
   234 
   234     def get_source(self, uri, source_config):
   235     def get_source(self, uri, source_config):
   235         source_config['uri'] = uri
   236         source_config['uri'] = uri
   245         self.schema = schema
   246         self.schema = schema
   246         if resetvreg:
   247         if resetvreg:
   247             # full reload of all appobjects
   248             # full reload of all appobjects
   248             self.vreg.reset()
   249             self.vreg.reset()
   249             self.vreg.set_schema(schema)
   250             self.vreg.set_schema(schema)
   250         self.hm.set_schema(schema)
   251         self.reset_hooks()
       
   252 
       
   253     def reset_hooks(self):
       
   254         self.hm.set_schema(self.schema)
   251         self.hm.register_system_hooks(self.config)
   255         self.hm.register_system_hooks(self.config)
   252         # instance specific hooks
   256         # instance specific hooks
   253         if self.config.instance_hooks:
   257         if self.config.instance_hooks:
   254             self.info('loading instance hooks')
   258             self.info('loading instance hooks')
   255             self.hm.register_hooks(self.config.load_hooks(self.vreg))
   259             self.hm.register_hooks(self.config.load_hooks(self.vreg))