I am trying to create a very simple whirlwind webapp that will ask the user for a username and password before the first (and only) page loads. I used the example provided in the CherryPy docs: http://cherrypy.readthedocs.org/en/latest/basics.html#authentication
Here is my special code for wsgi.py:
import cherrypy
from cherrypy.lib import auth_basic
from myapp import myapp
USERS = {'jon': 'secret'}
def validate_password(username, password):
if username in USERS and USERS[username] == password:
return True
return False
conf = {
'/': {
'tools.auth_basic.on': True,
'tools.auth_basic.realm': 'localhost',
'tools.auth_basic.checkpassword': validate_password
}
}
if __name__ == '__main__':
cherrypy.config.update({
'server.socket_host': '127.0.0.1',
'server.socket_port': 8080,
})
cherrypy.quickstart(myapp(), '/', conf)
The above code will give me a browser browser / password message, however, when I click OK at the prompt, I get the following error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/cherrypy/_cprequest.py", line 667, in respond
self.hooks.run('before_handler')
File "/usr/local/lib/python2.7/site-packages/cherrypy/_cprequest.py", line 114, in run
raise exc
TypeError: validate_password() takes exactly 2 arguments (3 given)
I'm not sure where he thinks he is getting this third argument. Any suggestions? Thank!
source
share