Beispiel #1
0
    def load(klass, request, response):
        """
		Load the session cookies from the request,
		returning a new instance with the response.
		"""
        try:
            id = request.cookies['SID'][1:-SIG_LEN - 1]
        except KeyError:
            raise NoSIDError
        else:
            c = SignedCookie(SECRET_KEY + id)
            c.load(request.environ['HTTP_COOKIE'])
            try:
                user = User.get_by_key_name(c['user'].value)
            except KeyError:
                user = None
            session = klass(user, response)
            session.cookies = c
            return session
Beispiel #2
0
	def load(klass, request, response):
		"""
		Load the session cookies from the request,
		returning a new instance with the response.
		"""
		try:
			id = request.cookies['SID'][1:-SIG_LEN-1]
		except KeyError:
			raise NoSIDError
		else:
			c = SignedCookie(SECRET_KEY + id)
			c.load(request.environ['HTTP_COOKIE'])
			try:
				user = User.get_by_key_name(c['user'].value)
			except KeyError:
				user = None
			session = klass(user, response)
			session.cookies = c
			return session