changeset 1:a02c4fcd7001

* optionally require auth * give a real version
author k0s <k0scist@gmail.com>
date Sun, 27 Dec 2009 13:29:27 -0500
parents 827f7577f940
children 0b5fce452087
files setup.py uploader/dispatcher.py
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Sat Nov 21 15:29:03 2009 -0500
+++ b/setup.py	Sun Dec 27 13:29:27 2009 -0500
@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 import sys, os
 
-version = "0.0"
+version = "0.1"
 
 setup(name='uploader',
       version=version,
--- a/uploader/dispatcher.py	Sat Nov 21 15:29:03 2009 -0500
+++ b/uploader/dispatcher.py	Sun Dec 27 13:29:27 2009 -0500
@@ -9,17 +9,21 @@
 class Dispatcher(object):
 
     ### class level variables
-    defaults = { 'directory': None}
+    defaults = { 'directory': None,
+                 'auth': 'False' }
 
     def __init__(self, **kw):
         for key in self.defaults:
             setattr(self, key, kw.get(key, self.defaults[key]))
         self.handlers = [ Get, Post ]
         assert os.path.exists(self.directory)
+        self.auth = self.auth.lower() == 'true'
 
     ### methods dealing with HTTP
     def __call__(self, environ, start_response):
         request = Request(environ)
+        if self.auth and not request.remote_user:
+            return exc.HTTPUnauthorized()(environ, start_response)
         for h in self.handlers:
             if h.match(request):
                 handler = h(self, request)