Mercurial > hg > CAPTCHAmiddleware
comparison captchamiddleware/example.py @ 0:21ec6325ae0e
initial import of CAPTCHA middleware; unfinished
author | k0s <k0scist@gmail.com> |
---|---|
date | Sun, 24 Jan 2010 23:15:57 -0500 |
parents | |
children | c861518b2a44 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:21ec6325ae0e |
---|---|
1 from webob import Response | |
2 from captchamiddleware import CAPTCHAmiddleware | |
3 from paste.httpexceptions import HTTPExceptionHandler | |
4 | |
5 def example_app(environ, start_response): | |
6 return Response('<html><body><form method="post">Hello, world!<input type="submit"/></form></body></html>')(environ, start_response) | |
7 | |
8 | |
9 def factory(global_conf, **app_conf): | |
10 """create a webob view and wrap it in middleware""" | |
11 keystring = 'captcha.' | |
12 args = dict([(key.split(keystr, 1)[-1], value) | |
13 for key, value in app_conf.items() | |
14 if key.startswith(keystr) ]) | |
15 return HTTPExceptionHandler(CAPTCHAmiddleware(example_app, **args)) | |
16 |