Mercurial > hg > CAPTCHAmiddleware
comparison 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 |
comparison
equal
deleted
inserted
replaced
3:b0ef5452a740 | 4:ce757057961c |
---|---|
63 return value == captcha | 63 return value == captcha |
64 | 64 |
65 def __call__(self, environ, start_response): | 65 def __call__(self, environ, start_response): |
66 request = Request(environ) | 66 request = Request(environ) |
67 if request.method == 'POST' and not request.remote_user: | 67 if request.method == 'POST' and not request.remote_user: |
68 return self.app(environ, start_response) | 68 if not self.check_captcha(request): |
69 location = request.referrer | |
70 return exc.HTTPSeeOther(location=location)(environ, start_response) | |
71 # TODO: set a cookie to record an error | |
72 # stage 2: record form values from request.POST, | |
73 # and reinsert them into the form so that users | |
74 # don't hate me ;) | |
69 | 75 |
70 return LXMLMiddleware.__call__(self, environ, start_response) | 76 return LXMLMiddleware.__call__(self, environ, start_response) |
71 | 77 |
72 def manipulate(self, environ, tree): | 78 def manipulate(self, environ, tree): |
73 """manipulate the DOM; should return an etree._Element""" | 79 """manipulate the DOM; should return an etree._Element""" |