annotate commentator/example.py @ 2:689b9d928dc8

add date, reflect api change of lxmlmiddleware
author k0s <k0scist@gmail.com>
date Tue, 26 Jan 2010 23:00:51 -0500
parents 1c95a3fa76c1
children c95f1dfed329
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
1 import os
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
2
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
3 from middleware import Commentator
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
4 from paste.httpexceptions import HTTPExceptionHandler
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
5 from paste.urlparser import StaticURLParser
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
6 from pkg_resources import resource_filename
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
7
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
8
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
9 def factory(global_conf, **app_conf):
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
10 """create a webob view and wrap it in middleware"""
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
11
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
12 keystr = 'commentator.'
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
13 args = dict([(key.split(keystr, 1)[-1], value)
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
14 for key, value in app_conf.items()
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
15 if key.startswith(keystr) ])
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
16 app = StaticURLParser(app_conf['directory'])
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
17 commentator = Commentator(app, **args)
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
18 return HTTPExceptionHandler(commentator)
1c95a3fa76c1 initial commit of commentator
k0s <k0scist@gmail.com>
parents:
diff changeset
19