web/application.py
branchstable
changeset 4484 d87989d91635
parent 4212 ab6573088b4a
child 4490 d45cde54d464
equal deleted inserted replaced
4457:297a63704761 4484:d87989d91635
   224     """
   224     """
   225 
   225 
   226     def __init__(self, config, debug=None,
   226     def __init__(self, config, debug=None,
   227                  session_handler_fact=CookieSessionHandler,
   227                  session_handler_fact=CookieSessionHandler,
   228                  vreg=None):
   228                  vreg=None):
   229         super(CubicWebPublisher, self).__init__()
   229         self.info('starting web instance from %s', config.apphome)
   230         # connect to the repository and get instance's schema
       
   231         if vreg is None:
   230         if vreg is None:
   232             vreg = cwvreg.CubicWebVRegistry(config, debug=debug)
   231             vreg = cwvreg.CubicWebVRegistry(config, debug=debug)
       
   232             need_set_schema = True
       
   233         else:
       
   234             # vreg is specified during test and the vreg is already properly
       
   235             # initialized. Even, reinitializing it may cause some unwanted
       
   236             # side effect due to unproper reloading of appobjects modules
       
   237             need_set_schema = False
   233         self.vreg = vreg
   238         self.vreg = vreg
   234         self.info('starting web instance from %s', config.apphome)
   239         # connect to the repository and get instance's schema
   235         self.repo = config.repository(vreg)
   240         self.repo = config.repository(vreg)
   236         if not vreg.initialized:
   241         if not vreg.initialized:
   237             self.config.init_cubes(self.repo.get_cubes())
   242             self.config.init_cubes(self.repo.get_cubes())
   238             vreg.init_properties(self.repo.properties())
   243             vreg.init_properties(self.repo.properties())
   239         vreg.set_schema(self.repo.get_schema())
   244         if need_set_schema:
       
   245             vreg.set_schema(self.repo.get_schema())
   240         # set the correct publish method
   246         # set the correct publish method
   241         if config['query-log-file']:
   247         if config['query-log-file']:
   242             from threading import Lock
   248             from threading import Lock
   243             self._query_log = open(config['query-log-file'], 'a')
   249             self._query_log = open(config['query-log-file'], 'a')
   244             self.publish = self.log_publish
   250             self.publish = self.log_publish