Mercurial > hg > TagInTheMiddle
annotate taginthemiddle/example.py @ 8:fc3491dfe374
correct function signature for reading tags file
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 05 May 2010 22:16:25 -0700 |
parents | bf4c763b0313 |
children | 3bf478cb3166 |
rev | line source |
---|---|
5 | 1 from middleware import Tagger |
0
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
2 from paste.httpexceptions import HTTPExceptionHandler |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
3 from paste.urlparser import StaticURLParser |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
4 from pkg_resources import resource_filename |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
5 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
6 def factory(global_conf, **app_conf): |
3
c2bb8f873aee
make a useful(?) example factory
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
7 """create an example view and wrap it in tagging middleware""" |
0
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 keystr = 'TagInTheMiddle.' |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
10 args = dict([(key.split(keystr, 1)[-1], value) |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 for key, value in app_conf.items() |
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 if key.startswith(keystr) ]) |
3
c2bb8f873aee
make a useful(?) example factory
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
13 app = StaticURLParser(app_conf['directory']) |
c2bb8f873aee
make a useful(?) example factory
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
14 tagger = Tagger(app, **args) |
c2bb8f873aee
make a useful(?) example factory
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
15 return HTTPExceptionHandler(tagger) |
0
1c5cbbde4299
initial commit of middleware tagging; doesnt yet work
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
16 |