# HG changeset patch # User Jeff Hammel # Date 1274712528 25200 # Node ID 3bf478cb31664b764813f2669db90543f24ce3c1 # Parent c85d42296c06985e9cd9d382aec9a9c218366752 make a BogusAuth class for testing purposes diff -r c85d42296c06 -r 3bf478cb3166 taginthemiddle/example.py --- 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'))