Mercurial > hg > CAPTCHAmiddleware
diff captchamiddleware/middleware.py @ 4:ce757057961c
flow contol now works; bumping version
author | k0s <k0scist@gmail.com> |
---|---|
date | Wed, 24 Feb 2010 20:11:25 -0500 |
parents | b0ef5452a740 |
children | 59245309f054 |
line wrap: on
line diff
--- a/captchamiddleware/middleware.py Tue Feb 23 20:08:22 2010 -0500 +++ b/captchamiddleware/middleware.py Wed Feb 24 20:11:25 2010 -0500 @@ -65,7 +65,13 @@ def __call__(self, environ, start_response): request = Request(environ) if request.method == 'POST' and not request.remote_user: - return self.app(environ, start_response) + if not self.check_captcha(request): + location = request.referrer + return exc.HTTPSeeOther(location=location)(environ, start_response) + # TODO: set a cookie to record an error + # stage 2: record form values from request.POST, + # and reinsert them into the form so that users + # don't hate me ;) return LXMLMiddleware.__call__(self, environ, start_response)