(req, id, word)
return """<html>
<head>
<title>PyCAPTCHA Example</title>
</head>
<body>
<h1>PyCAPTCHA Example</h1>
<h2>%s</h2>
<p><img src="image?id=%s"/></p>
<p><b>%s</b></p>
<p>You guessed: %s</p>
<p>Possible solutions: %s</p>
<p><a href="test">Try again</a></p>
</body>
</html>
""" % (test.__class__.__name__, test.id, result, word, ", ".join(test.solutions))
Grade a CAPTCHA given a solution word
Grade a CAPTCHA given a solution word
Grade a CAPTCHA given a solution word
def solution(req, id, word):
    """Grade a CAPTCHA given a solution word"""
    test = _getFactory(req).get(id)
    if not test:
        raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND

    if not test.valid:
        # Invalid tests will always return False, to prevent
        # random trial-and-error attacks. This could be confusing to a user...
        result = "Test invalidated, try another test"
    elif test.testSolutions([word]):
        result = "Correct"
    else:
        result = "Incorrect"

    return """<html>
<head>
<title>PyCAPTCHA Example</title>
</head>
<body>
<h1>PyCAPTCHA Example</h1>
<h2>%s</h2>
<p><img src="image?id=%s"/></p>
<p><b>%s</b></p>
<p>You guessed: %s</p>
<p>Possible solutions: %s</p>
<p><a href="test">Try again</a></p>
</body>
</html>
""" % (test.__class__.__name__, test.id, result, word, ", ".join(test.solutions))
def solution ( req , id , word ) : test = _getFactory ( req ) . get ( id ) if not test : raise apache . SERVER_RETURN , apache . HTTP_NOT_FOUND if not test . valid : # Invalid tests will always return False, to prevent # random trial-and-error attacks. This could be confusing to a user... result = "Test invalidated, try another test" elif test . testSolutions ( [ word ] ) : result = "Correct" else : result = "Incorrect" return """<html>
<head>
<title>PyCAPTCHA Example</title>
</head>
<body>
<h1>PyCAPTCHA Example</h1>
<h2>%s</h2>
<p><img src="image?id=%s"/></p>
<p><b>%s</b></p>
<p>You guessed: %s</p>
<p>Possible solutions: %s</p>
<p><a href="test">Try again</a></p>
</body>
</html>
""" % ( test . __class__ . __name__ , test . id , result , word , ", " . join ( test . solutions ) )