changeset 2:b03602153de2

removing more cruft
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 27 Feb 2012 16:05:34 -0800
parents 24b8d06eae53
children f5360bb59e41
files simpypi/dispatcher.py simpypi/factory.py
diffstat 2 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/simpypi/dispatcher.py	Mon Feb 27 15:57:01 2012 -0800
+++ b/simpypi/dispatcher.py	Mon Feb 27 16:05:34 2012 -0800
@@ -4,12 +4,10 @@
 """
 
 import os
-
 from handlers import Index
+from webob import Request, Response, exc
 
-from paste.fileapp import FileApp
-from pkg_resources import resource_filename
-from webob import Request, Response, exc
+here = os.path.dirname(os.path.abspath(__file__))
 
 class Dispatcher(object):
 
@@ -18,26 +16,30 @@
                 'template_dirs': '',
                 }
 
-    def __init__(self, **kw):
+    def __init__(self, directory, **kw):
+
+        self.directory = directory
+        assert os.path.exists(directory)
 
         # set instance parameters from kw and defaults
-        for key in self.defaults:
-            setattr(self, key, kw.get(key, self.defaults[key]))
-        self.auto_reload = self.auto_reload.lower() == 'true'
+# XXX unneeded for now
+#        for key in self.defaults:
+#            setattr(self, key, kw.get(key, self.defaults[key]))
+#        self.auto_reload = self.auto_reload.lower() == 'true'
 
         # request handlers
         self.handlers = [ Index ]
 
         # template directories
-        self.template_dirs = self.template_dirs.split()
-        self.template_dirs.append(resource_filename(__name__, 'templates'))
+#        self.template_dirs = self.template_dirs.split()
+        self.template_dirs = [os.path.join(here, 'templates')]
 
     def __call__(self, environ, start_response):
 
         # get a request object
         request = Request(environ)
 
-        # get the path 
+        # get the path
         path = request.path_info.strip('/').split('/')
         if path == ['']:
             path = []
--- a/simpypi/factory.py	Mon Feb 27 15:57:01 2012 -0800
+++ b/simpypi/factory.py	Mon Feb 27 16:05:34 2012 -0800
@@ -25,6 +25,11 @@
     return HTTPExceptionHandler(PassthroughFileserver(app, resource_filename(__name__, 'static')))
 
 if __name__ == '__main__':
+    import shutil
     import tempfile
     from wsgiref import simple_server
-    app = factory
+    tempdir = tempfile.mkdtemp()
+    try:
+        app = factory
+    finally:
+        shutil.rmtree(tempdir)