changeset 13:b8c636b0b567

make work for non pastescript frameworks
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 05 Jul 2011 23:37:52 -0700
parents f60ad139acc1
children 916d45d4f921
files setup.py uploader/handlers.py
diffstat 2 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Tue Feb 02 17:58:00 2010 +0000
+++ b/setup.py	Tue Jul 05 23:37:52 2011 -0700
@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 import sys, os
 
-version = "0.2.3"
+version = "0.2.4"
 
 setup(name='uploader',
       version=version,
--- a/uploader/handlers.py	Tue Feb 02 17:58:00 2010 +0000
+++ b/uploader/handlers.py	Tue Jul 05 23:37:52 2011 -0700
@@ -20,11 +20,11 @@
         return '/'.join(path)
 
     def redirect(self, location):
-        raise exc.HTTPSeeOther(location=location)
+        return exc.HTTPSeeOther(location=location)
 
 class Get(Handler):
 
-    form = """<html><body><form name="upload_form" method="post" enctype="multipart/form-data">
+    form = """<form name="upload_form" method="post" enctype="multipart/form-data">
 <input type="file" name="file"/><input type="submit" value="upload"/></form></body></html>"""
 
     @classmethod
@@ -34,7 +34,11 @@
         return request.method == 'GET'
 
     def __call__(self):
-        return Response(content_type='text/html', body=self.form)
+        form = "<html><body>"
+        if 'uploaded' in self.request.GET:
+            form += '<div>%s uploaded successfully</div>' % self.request.GET['uploaded']
+        form += self.form + '</body></html>'
+        return Response(content_type='text/html', body=form)
 
 class Post(Handler):
 
@@ -53,7 +57,7 @@
         fin = self.request.POST['file']
         _path = os.path.join(self.app.directory, fin.filename)
         self.write(fin, _path)
-        self.redirect(self.link('/'))
+        return self.redirect(self.link('/?uploaded=' + fin.filename))
 
 def path(directory, request):
     if os.sep == '/':
@@ -85,5 +89,5 @@
         _path = path(self.app.directory, self.request)
         _path = os.path.join(_path, fin.filename)
         self.write(fin, _path)
-        self.redirect(self.link(self.request.path_info))
+        return self.redirect(self.link(self.request.path_info))