Пример #1
0
    def pre_dispatch(self, handler):
        """Loads the current user and sets it as a handler property."""
        current_user = auth.get_current_user()

        handler.request.context.update({
            'current_user':     current_user,
            'login_url':        auth.create_login_url(request.url),
            'logout_url':       auth.create_logout_url('/'),
            'is_authenticated': auth.is_authenticated(),
        })

        setattr(handler, 'current_user', current_user)
Пример #2
0
 def dispatch(self, *args, **kwargs):
     """Sets up a lot of common context variables as well as session stuff."""
             
     if self.session and self.session.get('key') == None:
         self.session['key'] = key_generator.create_key()
     
     self.context = self.context or {}
     self.context['user']        = auth.get_current_user()
     self.context['signup_url']  = auth.create_signup_url(request.url)
     self.context['login_url']   = auth.create_login_url(request.url)
     self.context['logout_url']  = auth.create_logout_url(request.url)
     
     return RequestHandler.dispatch(self, *args, **kwargs)
     
Пример #3
0
 def get_current_user(cls):
     return auth.get_current_user()