def __init__(self, root, templates_path, config={}): self.statics = config.get('statics', 'public') self.autoreload_templates = config.get('autoreload', False) self.force_request_encoding = config.get('force_request_encoding', 'utf-8') requested_authenticator = config.get('authenticator') if not requested_authenticator: self.authenticator = CookieAuthenticator() else: self.authenticator = requested_authenticator() self.root = root(self, templates_path, config.get('helpers', SpynachHelpers()))
class SpynachCore(object): def __init__(self, root, templates_path, config={}): self.statics = config.get('statics', 'public') self.autoreload_templates = config.get('autoreload', False) self.force_request_encoding = config.get('force_request_encoding', 'utf-8') requested_authenticator = config.get('authenticator') if not requested_authenticator: self.authenticator = CookieAuthenticator() else: self.authenticator = requested_authenticator() self.root = root(self, templates_path, config.get('helpers', SpynachHelpers())) def __call__(self, environ, start_response): request = Request(environ=environ) environ['spynach.locals'].register(environ, a_request, request) response = Response(body="spynach Default Page", content_type='text/html', charset='utf-8') environ['spynach.locals'].register(environ, a_response, response) if self.force_request_encoding: request.charset = self.force_request_encoding static_path = self.statics + request.path_info if os.path.exists(static_path) and os.path.isfile(static_path): response = FileApp(static_path) else: try: self.authenticator.authenticate(request) self.root._dispatch(request) self.authenticator.inject_cookie(response) except HTTPException, e: response = e self.authenticator.inject_cookie(response) return response(environ, start_response)