def dispatch(self, environ, start_response): try: local.request = Request(environ) local.response = Response() local.session = Session(local.request.cookies.get("session")) try: local.url_adapter = url_adapter = url_map.bind_to_environ(environ) try: endpoint, params = url_adapter.match() except NotFound: endpoint = "notfound" params = {} if not endpoint in ("notfound", "misc.enter_title_do") and document().title == None: endpoint = "misc.enter_title_form" local.endpoint = endpoint endpoints[endpoint](**params) except: if self.debug: raise endpoints["error"]() response = local.response local.session.set_cookie(local.response) except: if self.debug: raise response = Response("Fejlsidens fejlside.") return response(environ, start_response)
def dispatch(self, environ, start_response): try: local.request = Request(environ) local.response = Response() local.session = Session(local.request.cookies.get("session"), 600) local.cache = {} try: local.url_adapter = url_adapter = url_map.bind_to_environ(environ) try: endpoint, params = url_adapter.match() except NotFound: endpoint = "notfound" params = {} if not endpoint in ("notfound", "login.authenticate") and local.session.get("uid") is None: endpoint = "login.form" local.endpoint = endpoint endpoints[endpoint](**params) except: if self.debug: raise endpoints["error"]() response = local.response local.session.save() local.session.set_cookie(local.response) except: if self.debug: raise response = Response("Fejlsidens fejlside.") return response(environ, start_response)
def dispatch(self, environ, start_response): try: local.request = Request(environ) local.response = Response() local.session = Session(local.request.cookies.get("session")) try: local.url_adapter = url_adapter = url_map.bind_to_environ(environ) try: endpoint, params = url_adapter.match() except NotFound: endpoint = "notfound" params = {} local.endpoint = endpoint endpoints[endpoint](**params) except: if self.debug: raise responders.error() response = local.response local.session.save() local.session.set_cookie(local.response) except: if self.debug: raise response = Response("Fejlsidens fejlside.") return response(environ, start_response)
def dispatch(self, environ, start_response): try: local.request = Request(environ) local.response = Response() local.session = Session(local.request.cookies.get("session")) try: local.url_adapter = url_adapter = url_map.bind_to_environ( environ) try: endpoint, params = url_adapter.match() except NotFound: endpoint = "notfound" params = {} local.endpoint = endpoint endpoints[endpoint](**params) except: if self.debug: raise responders.error() response = local.response local.session.save() local.session.set_cookie(local.response) except: if self.debug: raise response = Response("Fejlsidens fejlside.") return response(environ, start_response)
def appdispatch(self, environ, start_response): local.request = Request(environ) local.response = Response() local.session = Session(local.request.cookies.get("session"), 600) try: local.url_adapter = url_adapter = url_map.bind_to_environ(environ) try: endpt, params = url_adapter.match() except NotFound: endpt, params = "notfound", {} local.endpt = endpt endpts[endpt](**params) except: if self.debug: raise else: log.exception( "Exception in %s with params %s", endpt, repr(params) ) local.endpt = "error" endpts["error"]() response = local.response local.session.save() local.session.set_cookie(local.response) return response(environ, start_response)
def dispatch(request): import app.controllers.document from app.controllers.error import notfound, error from app.mapping import url_map, endpts from app.utils.session import Session from app.db import sessiondb try: url_adapter = url_map.bind_to_environ(request.environ) session_id = request.cookies.get("session_id") if session_id is not None: try: session_id = int(session_id) except ValueError: session_id = None session_token = request.cookies.get("session_token") session = Session(sessiondb, session_id, session_token, ttl=60) try: endpt, params = url_adapter.match() response = endpts[endpt](request=request, url_adapter=url_adapter, session=session, **params) except NotFound: response = notfound(request=request, url_adapter=url_adapter) if session.token is None or session.id is None: return response response.set_cookie("session_id", unicode(session.id), max_age=99999999) response.set_cookie("session_token", session.token, max_age=99999999) return response except: # Let werkzeug handle the exception if debug: raise # Log error and return error page log.exception("Exception in %s with params %s", endpt, repr(params)) return error(request = request)
def appdispatch(self, environ, start_response): local.request = Request(environ) local.response = Response() local.session = Session(local.request.cookies.get("session"), 600) try: local.url_adapter = url_adapter = url_map.bind_to_environ(environ) try: endpoint, params = url_adapter.match() except NotFound: endpoint = "notfound" params = {} local.endpoint = endpoint endpoints[endpoint](**params) except: if self.debug: raise else: logger.exception("Exception") endpoints["error"]() response = local.response local.session.save() local.session.set_cookie(local.response) return response(environ, start_response)