Mercurial > hg > commentator
comparison 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 |
comparison
equal
deleted
inserted
replaced
5:451169e51935 | 6:c95f1dfed329 |
---|---|
14 for key, value in app_conf.items() | 14 for key, value in app_conf.items() |
15 if key.startswith(keystr) ]) | 15 if key.startswith(keystr) ]) |
16 app = StaticURLParser(app_conf['directory']) | 16 app = StaticURLParser(app_conf['directory']) |
17 commentator = Commentator(app, **args) | 17 commentator = Commentator(app, **args) |
18 return HTTPExceptionHandler(commentator) | 18 return HTTPExceptionHandler(commentator) |
19 | |
20 try: | |
21 from captchamiddleware import CAPTCHAmiddleware | |
19 | 22 |
23 def captcha_factory(global_conf, **app_conf): | |
24 """create a webob view and wrap it in middleware""" | |
25 | |
26 # set up commenting on static files | |
27 keystr = 'commentator.' | |
28 args = dict([(key.split(keystr, 1)[-1], value) | |
29 for key, value in app_conf.items() | |
30 if key.startswith(keystr) ]) | |
31 app = StaticURLParser(app_conf['directory']) | |
32 commentator = Commentator(app, **args) | |
33 | |
34 # install the CAPTCHAmiddleware | |
35 keystring = 'captcha.' | |
36 args = dict([(key.split(keystr, 1)[-1], value) | |
37 for key, value in app_conf.items() | |
38 if key.startswith(keystr) ]) | |
39 captcha = CAPTCHAmiddleware(commentator, **args) | |
40 | |
41 return HTTPExceptionHandler(captcha) | |
42 | |
43 except ImportError: | |
44 pass |