from mod_python import apache def authenhandler(req): pw = req.get_basic_auth_pw() user = req.connection.user if user == "spam" and pw == "eggs": return apache.OK else: return apache.HTTP_UNAUTHORIZED