def _compile(self, env): """configuration to python object""" copied = copy.deepcopy(env) copied['route'] = self._compile_routes(copied['route']) copied['handler'] = module.localimport(copied['handler']) if 'hooks' in copied: copied['hooks'] = [module.localimport(hook) for hook in copied['hooks']] return copied
def __init__(self, request, match, config={}): self.config = config self.match = match for attr in self.attributes: setattr(self, attr, getattr(request, attr)) self._handler = wsgi_server.ServerHandler(self.rfile, self.wfile, self.get_stderr(), self.get_environ()) self._handler.request_handler = self self.application = module.localimport(self.config.get('app'))
def _precompile(self, config): """pre-compile config file""" copied = copy.deepcopy(config) for netloc in copied['apps']: envs = copied['apps'][netloc] if type(envs) == list or type(envs) == tuple: copied['apps'][netloc] = [self._compile(env) for env in envs] elif type(envs) == dict: copied['apps'][netloc] = self._compile(envs) copied['hooks'] = [module.localimport(hook) for hook in copied.get('hooks', [])] return copied