diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/captchamiddleware/example.py	Sun Jan 24 23:15:57 2010 -0500
@@ -0,0 +1,16 @@
+from webob import Response
+from captchamiddleware import CAPTCHAmiddleware
+from paste.httpexceptions import HTTPExceptionHandler
+
+def example_app(environ, start_response):
+    return Response('<html><body><form method="post">Hello, world!<input type="submit"/></form></body></html>')(environ, start_response)
+
+
+def factory(global_conf, **app_conf):
+    """create a webob view and wrap it in middleware"""
+    keystring = 'captcha.'
+    args = dict([(key.split(keystr, 1)[-1], value)
+                 for key, value in app_conf.items()
+                 if key.startswith(keystr) ])
+    return HTTPExceptionHandler(CAPTCHAmiddleware(example_app, **args))
+