view 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 source

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))