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, 21 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/taginthemiddle/example.py
+++ b/taginthemiddle/example.py
@@ -1,16 +1,29 @@
 from middleware import Tagger
 from paste.httpexceptions import HTTPExceptionHandler
 from paste.urlparser import StaticURLParser
 from pkg_resources import resource_filename
 
+class BogusAuth(object):
+  """
+  a bogus authenticator class
+  """
+
+  def __init__(self, app, user):
+    self.app = app
+    self.user = user
+
+  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"""
+  """create an example view and wrap it in tagging middleware"""
 
-    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)
+  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'))