#NEWLINE# def do_check( self ) : #NEWLINE# #INDENT# 'Assert username. May raise redirect, or return True if request handled.' #NEWLINE# sess = cherrypy . session #NEWLINE# request = cherrypy . serving . request #NEWLINE# response = cherrypy . serving . response #NEWLINE# username = sess . get ( self . session_key ) #NEWLINE# if ( not username ) : #NEWLINE# #INDENT# sess [ self . session_key ] = username = self . anonymous ( ) #NEWLINE# if self . debug : #NEWLINE# #INDENT# cherrypy . log ( 'No session[username], trying anonymous' , 'TOOLS.SESSAUTH' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not username ) : #NEWLINE# #INDENT# url = cherrypy . url ( qs = request . query_string ) #NEWLINE# if self . debug : #NEWLINE# #INDENT# cherrypy . log ( ( 'No username, routing to login_screen with from_page %r' % response ) , 'TOOLS.SESSAUTH' ) #NEWLINE# #UNINDENT# response . body = self . login_screen ( url ) #NEWLINE# if ( 'Content-Length' in response . headers ) : #NEWLINE# #INDENT# del response . headers [ 'Content-Length' ] #NEWLINE# #UNINDENT# return True #NEWLINE# #UNINDENT# if self . debug : #NEWLINE# #INDENT# cherrypy . log ( ( 'Setting request.login to %r' % username ) , 'TOOLS.SESSAUTH' ) #NEWLINE# #UNINDENT# request . login = username #NEWLINE# self . on_check ( username )