""" (C) Gregory Trubetskoy, 1998 This file is part of Httpdapy. This is an example of how to do authentication using Python. By supplying different userid's you can see all possible different reactions of the server. "proceed" will let you in "aborted" will show server error "noaction" will show the login dialog box again "forbidden" will show Forbidden error "anuthing else" will let you right through. """ import httpdapi class AuthHandler( httpdapi.AuthHandler ): def Handle( self ): try: user = self.rq.vars["user"] pw = self.pb.vars["pw"] except: user, pw = None, None if user == 'proceed': return httpdapi.REQ_PROCEED elif user == 'aborted': return httpdapi.REQ_ABORTED elif user == 'noaction': return httpdapi.REQ_NOACTION elif user == 'forbidden': self.rq.protocol_status(self.sn, httpdapi.PROTOCOL_FORBIDDEN) return httpdapi.REQ_ABORTED else: return httpdapi.REQ_PROCEED