changeset 7:a8c60480fce0

make query_string argument more universal
author k0s <k0scist@gmail.com>
date Sun, 27 Dec 2009 18:45:28 -0500
parents d2990750e5d6
children 3be4b669983c
files setup.py uploader/handlers.py
diffstat 2 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py
+++ b/setup.py
@@ -1,12 +1,12 @@
 from setuptools import setup, find_packages
 import sys, os
 
-version = "0.2.2"
+version = "0.2.3"
 
 setup(name='uploader',
       version=version,
       description="a file uploader app",
       long_description="""
 """,
       classifiers=[], # Get strings from http://www.python.org/pypi?%3Aaction=list_classifiers
       author='Ethan Jucovy',
--- a/uploader/handlers.py
+++ b/uploader/handlers.py
@@ -24,16 +24,18 @@ class Handler(object):
 
 class Get(Handler):
 
     form = """<html><body><form name="upload_form" method="post" enctype="multipart/form-data">
 <input type="file" name="file"/><input type="submit" value="upload"/></form></body></html>"""
 
     @classmethod
     def match(cls, app, request):
+        if app.query_string and (app.query_string not in request.GET):
+            return False
         return request.method == 'GET'
 
     def __call__(self):
         return Response(content_type='text/html', body=self.form)
 
 class Post(Handler):
 
     @classmethod
@@ -57,19 +59,17 @@ def path(directory, request):
     if os.sep == '/':
         return os.path.join(directory, request.path_info.strip('/'))
     return os.path.join(directory, *request.path_info.strip('/').split('/'))
 
 class SubpathGet(Get):
     
     @classmethod
     def match(cls, app, request):
-        if request.method != 'GET':
-            return False
-        if app.query_string and (app.query_string not in request.GET):
+        if not Get.match(cls, app, request):
             return False
         _path = path(app.directory, request)
         if os.path.exists(_path) and os.path.isdir(_path):
             return True
         
 class SubpathPost(Post):
     
     @classmethod