Mercurial > hg > TagInTheMiddle
changeset 18:3bf478cb3166
make a BogusAuth class for testing purposes
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 24 May 2010 07:48:48 -0700 |
parents | c85d42296c06 |
children | 57ca873ed9bf |
files | taginthemiddle/example.py |
diffstat | 1 files changed, 22 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/taginthemiddle/example.py Mon May 24 07:44:39 2010 -0700 +++ b/taginthemiddle/example.py Mon May 24 07:48:48 2010 -0700 @@ -3,14 +3,27 @@ from paste.urlparser import StaticURLParser from pkg_resources import resource_filename -def factory(global_conf, **app_conf): - """create an example view and wrap it in tagging middleware""" +class BogusAuth(object): + """ + a bogus authenticator class + """ + + def __init__(self, app, user): + self.app = app + self.user = user - keystr = 'TagInTheMiddle.' - args = dict([(key.split(keystr, 1)[-1], value) - for key, value in app_conf.items() - if key.startswith(keystr) ]) - app = StaticURLParser(app_conf['directory']) - tagger = Tagger(app, **args) - return HTTPExceptionHandler(tagger) + def call(self, environ, start_response): + environ['REMOTE_USER'] = self.user + return self.app(environ, start_response) + +def factory(global_conf, **app_conf): + """create an example view and wrap it in tagging middleware""" + + keystr = 'tags.' + args = dict([(key.split(keystr, 1)[-1], value) + for key, value in app_conf.items() + if key.startswith(keystr) ]) + app = StaticURLParser(app_conf['directory']) + tagger = Tagger(app, **args) + return HTTPExceptionHandler(BogusAuth(tagger, 'foo'))