diff commentator/example.py @ 6:c95f1dfed329

some work to get commenting + captchas working together
author k0s <k0scist@gmail.com>
date Tue, 02 Mar 2010 11:44:10 -0500
parents 1c95a3fa76c1
children
line wrap: on
line diff
--- 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