def user_required(handler):
 def check_login(self, *args, **kwargs):
  '\n            If handler has no login_url specified invoke a 403 error\n        '
  if (self.request.query_string != ''):
   query_string = ('?' + self.request.query_string)
  else:
   query_string = ''
  continue_url = (self.request.path_url + query_string)
  login_url = self.uri_for('login', **{'continue': continue_url})
  try:
   auth = self.auth.get_user_by_session()
   if (not auth):
    try:
     self.redirect(login_url, abort=True)
    except (AttributeError, KeyError) as e:
     self.abort(403)
  except AttributeError as e:
   logging.error(e)
   self.auth.unset_session()
   self.redirect(login_url)
  return handler(self, *args, **kwargs)
 return check_login

def user_required ( handler ) : def check_login ( self , * args , ** kwargs ) : if ( self . request . query_string != '' ) : query_string = ( '?' + self . request . query_string ) else : query_string = '' continue_url = ( self . request . path_url + query_string ) login_url = self . uri_for ( 'login' , ** { 'continue' : continue_url } ) try : auth = self . auth . get_user_by_session ( ) if ( not auth ) : try : self . redirect ( login_url , abort = True ) except ( AttributeError , KeyError ) as e : self . abort ( 403 ) except AttributeError as e : logging . error ( e ) self . auth . unset_session ( ) self . redirect ( login_url ) return handler ( self , * args , ** kwargs ) return check_login
decorator for checking if theres a user associated with the current session .