web/application.py
changeset 9031 6ff29f2879da
parent 9030 c1d5e8ca15ea
child 9032 629a8d49d6f5
equal deleted inserted replaced
9030:c1d5e8ca15ea 9031:6ff29f2879da
   248     to publish HTTP request.
   248     to publish HTTP request.
   249 
   249 
   250     The http server will call its main entry point ``application.handle_request``.
   250     The http server will call its main entry point ``application.handle_request``.
   251 
   251 
   252     .. automethod:: cubicweb.web.application.CubicWebPublisher.main_handle_request
   252     .. automethod:: cubicweb.web.application.CubicWebPublisher.main_handle_request
       
   253 
       
   254     You have to provide both a repository and web-server config at
       
   255     initialization. In all in one instance both config will be the same.
   253     """
   256     """
   254 
   257 
   255     def __init__(self, config,
   258     def __init__(self, repo, config, session_handler_fact=CookieSessionHandler):
   256                  session_handler_fact=CookieSessionHandler):
       
   257         self.info('starting web instance from %s', config.apphome)
   259         self.info('starting web instance from %s', config.apphome)
   258         # connect to the repository and get instance's schema
   260         self.repo = repo
   259         self.repo = config.repository()
   261         self.vreg = repo.vreg
   260         vreg = self.vreg = self.repo.vreg
   262         # get instance's schema
   261         if not vreg.initialized:
   263         if not self.vreg.initialized:
   262             config.init_cubes(self.repo.get_cubes())
   264             config.init_cubes(self.repo.get_cubes())
   263             vreg.init_properties(self.repo.properties())
   265             self.vreg.init_properties(self.repo.properties())
   264             vreg.set_schema(self.repo.get_schema())
   266             self.vreg.set_schema(self.repo.get_schema())
   265         # set the correct publish method
   267         # set the correct publish method
   266         if config['query-log-file']:
   268         if config['query-log-file']:
   267             from threading import Lock
   269             from threading import Lock
   268             self._query_log = open(config['query-log-file'], 'a')
   270             self._query_log = open(config['query-log-file'], 'a')
   269             self.handle_request = self.log_handle_request
   271             self.handle_request = self.log_handle_request