From 791e9ed503f71b2297f64899fda83727d7858d59 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 13 Jan 2011 10:00:35 -0800 Subject: [PATCH] Some debug stuff. --- server/appengine/main.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/server/appengine/main.py b/server/appengine/main.py index f117c83f2..8c4eeecec 100644 --- a/server/appengine/main.py +++ b/server/appengine/main.py @@ -283,22 +283,20 @@ class UploadHandler(blobstore_handlers.BlobstoreUploadHandler): if 'blob-key' in value.type_options: blob_info = blobstore.parse_blob_info(value) blob_info_dict[value.name] = blob_info + logging.info("got blob: %s" % value.name) self.store_blob(value.name, blob_info, error_messages) if error_messages: logging.error('Upload errors: %r', error_messages) blobstore.delete(blob_info_dict.values()) - self.redirect('/error?%s' % '&'.join( + self.response.set_status(303) + # TODO: fix up this format + self.response.headers.add_header("Location", '/error?%s' % '&'.join( 'error_message=%s' % urllib.quote(m) for m in error_messages)) else: query = ['/nonstandard/upload_complete?camliversion=1'] query.extend('blob%d=%s' % (i + 1, k) for i, k in enumerate(blob_info_dict.iterkeys())) - # Previous, Brett had: - #self.redirect('&'.join(query)) - # But a 302 implies a new POST, and Brett's re-use of PreUploadHandler - # implies that he meant for clients to do a GET on subsequent requests, - # so 303 is probably what he wanted: self.response.set_status(303) self.response.headers.add_header("Location", str('&'.join(query))) @@ -312,9 +310,19 @@ class ErrorHandler(webapp.RequestHandler): self.response.set_status(400) +class DebugUploadForm(webapp.RequestHandler): + def get(self): + self.response.headers['Content-Type'] = 'text/html' + uploadurl = blobstore.create_upload_url('/upload_complete') + self.response.out.write('
' % uploadurl) + self.response.out.write('') + self.response.out.write('
') + + APP = webapp.WSGIApplication( [ ('/', HelloHandler), + ('/debug/upform', DebugUploadForm), ('/camli/enumerate-blobs', ListHandler), ('/camli/preupload', PreuploadHandler), ('/camli/([^/]+)', GetHandler),