# HG changeset patch # User k0s # Date 1267060285 18000 # Node ID ce757057961c6a2bcb7756e3ed26868fcff93e62 # Parent b0ef5452a74005e2211cc50467e60624c4eaf857 flow contol now works; bumping version diff -r b0ef5452a740 -r ce757057961c captchamiddleware/example.py --- a/captchamiddleware/example.py Tue Feb 23 20:08:22 2010 -0500 +++ b/captchamiddleware/example.py Wed Feb 24 20:11:25 2010 -0500 @@ -3,7 +3,12 @@ from paste.httpexceptions import HTTPExceptionHandler def example_app(environ, start_response): - return Response('

method=%s

Hello, world!
' % environ['REQUEST_METHOD'])(environ, start_response) + method = environ['REQUEST_METHOD'] + form = '' + if method != 'POST': + form = '
Hello, world!
' + + return Response('

method=%s

%s' % (method, form))(environ, start_response) def factory(global_conf, **app_conf): diff -r b0ef5452a740 -r ce757057961c captchamiddleware/middleware.py --- 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) diff -r b0ef5452a740 -r ce757057961c setup.py --- a/setup.py Tue Feb 23 20:08:22 2010 -0500 +++ b/setup.py Wed Feb 24 20:11:25 2010 -0500 @@ -1,7 +1,7 @@ from setuptools import setup, find_packages import sys, os -version = "0.1.1" +version = "0.2" setup(name='CAPTCHAmiddleware', version=version, @@ -11,7 +11,7 @@ classifiers=[], # Get strings from http://www.python.org/pypi?%3Aaction=list_classifiers author='Jeff Hammel', author_email='k0scist@gmail.com', - url='http://k0s.org', + url='http://k0s.org/hg', license="GPL", packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), include_package_data=True,