# HG changeset patch # User k0s # Date 1267548250 18000 # Node ID c95f1dfed329850308a4cc51911590b62adc9b5e # Parent 451169e5193534596decf6e6113f1ec00a88fdff some work to get commenting + captchas working together diff -r 451169e51935 -r c95f1dfed329 commentator/example.py --- a/commentator/example.py Fri Feb 26 12:27:25 2010 -0500 +++ b/commentator/example.py Tue Mar 02 11:44:10 2010 -0500 @@ -16,4 +16,29 @@ app = StaticURLParser(app_conf['directory']) commentator = Commentator(app, **args) return HTTPExceptionHandler(commentator) + +try: + from captchamiddleware import CAPTCHAmiddleware + def captcha_factory(global_conf, **app_conf): + """create a webob view and wrap it in middleware""" + + # set up commenting on static files + keystr = 'commentator.' + args = dict([(key.split(keystr, 1)[-1], value) + for key, value in app_conf.items() + if key.startswith(keystr) ]) + app = StaticURLParser(app_conf['directory']) + commentator = Commentator(app, **args) + + # install the CAPTCHAmiddleware + keystring = 'captcha.' + args = dict([(key.split(keystr, 1)[-1], value) + for key, value in app_conf.items() + if key.startswith(keystr) ]) + captcha = CAPTCHAmiddleware(commentator, **args) + + return HTTPExceptionHandler(captcha) + +except ImportError: + pass diff -r 451169e51935 -r c95f1dfed329 comments+captcha.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/comments+captcha.ini Tue Mar 02 11:44:10 2010 -0500 @@ -0,0 +1,25 @@ +#!/usr/bin/env paster + +[DEFAULT] +debug = true +email_to = k0scist@gmail.com +smtp_server = localhost +error_email_from = paste@localhost + +[server:main] +use = egg:Paste#http +host = 0.0.0.0 +port = 1080 + +[composite:main] +use = egg:Paste#urlmap +/ = commentator + +set debug = false + +[app:commentator] +paste.app_factory = commentator.example:captcha_factory +directory = %(here)s/example +commentator.database = %(here)s/test.pck +commentator.pattern = (.*)#.//div[@id='comment_on_this'] -> ${1} +#commentator.pattern = /blog/.*##([0-9]{14})->/blog/$1 # for bitsyblog diff -r 451169e51935 -r c95f1dfed329 setup.py --- a/setup.py Fri Feb 26 12:27:25 2010 -0500 +++ b/setup.py Tue Mar 02 11:44:10 2010 -0500 @@ -31,6 +31,7 @@ # -*- Entry points: -*- [paste.app_factory] commentator = commentator.example:factory + captcha_comments = commentator.example:captcha_factory """, )