示例#1
0
	def dispatch(self, environ, start_response):
		local.application = self
		request = Request(environ)

		## this is where we load the cookie if any, or create a new one
		sid = request.cookies.get('kif415-helfer-login')
		if sid is None:
			request.session = session_store.new()
		else:
			request.session = session_store.get(sid)
			if not validate_session(request.session):
				session_store.delete(request.session)
				request.session = session_store.new()
				request.session['logout'] = True

		local.url_adapter = adapter = url_map.bind_to_environ(environ)
		try:
			endpoint, values = adapter.match()
			handler = getattr(views, endpoint)
			response = handler(request, **values)
		except HTTPException, e:
			response = e # XXX hrm? this breaks when setting cookies!
示例#2
0
    def dispatch(self, environ, start_response):
        local.application = self
        request = Request(environ)
        local.url_adapter = adapter = url_map.bind_to_environ(environ)

        request.debug = self.debug
        
        request.session = SecureCookie.load_cookie(request, 
                                                   key='com.kinaj.session', 
                                                   secret_key='kinaj')
        
        try:
            endpoint, values = adapter.match()
            handler = getattr(views, endpoint)
            response = handler(request, **values)
            
        except NotFound, e:
            response = views.not_found(request)
            response.status_code = 404