# HG changeset patch
# User Jeff Hammel <jhammel@mozilla.com>
# Date 1273122316 25200
# Node ID c2bb8f873aee2a590f2c6c96a9bbbdcc7536ebdf
# Parent  1182315b18acbe80cc632e7af3a6468eb14094b7
make a useful(?) example factory

diff -r 1182315b18ac -r c2bb8f873aee taginthemiddle/example.py
--- a/taginthemiddle/example.py	Tue May 04 19:15:21 2010 -0700
+++ b/taginthemiddle/example.py	Wed May 05 22:05:16 2010 -0700
@@ -1,31 +1,16 @@
-import os
-
-from dispatcher import Dispatcher
+from dispatcher import Tagger
 from paste.httpexceptions import HTTPExceptionHandler
 from paste.urlparser import StaticURLParser
 from pkg_resources import resource_filename
 
-class PassthroughFileserver(object):
-    """serve files if they exist"""
-
-    def __init__(self, app, directory):
-        self.app = app
-        self.directory = directory
-        self.fileserver = StaticURLParser(self.directory)
-
-    def __call__(self, environ, start_response):
-        path = environ['PATH_INFO'].strip('/')
-        if path and os.path.exists(os.path.join(self.directory, path)):
-            return self.fileserver(environ, start_response)
-        return self.app(environ, start_response)
-
 def factory(global_conf, **app_conf):
-    """create a webob view and wrap it in 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 = Dispatcher(**args)
-    return HTTPExceptionHandler(PassthroughFileserver(app, resource_filename(__name__, 'static')))
+    app = StaticURLParser(app_conf['directory'])
+    tagger = Tagger(app, **args)
+    return HTTPExceptionHandler(tagger)