From 3d99a4757212d6cd8e8b515b42b501b3231cccaf Mon Sep 17 00:00:00 2001
From: Martijn Vermaat <martijn@vermaat.name>
Date: Wed, 16 Feb 2011 10:43:23 +0000
Subject: [PATCH] Fixed the genbank uploader for use by LOVD.

LOVD insists (incorrectly) on uploading a genbank file urlencoded while we
ask for multipart/form-data. We now also accept urlencoded requests to be
done with it.



git-svn-id: https://humgenprojects.lumc.nl/svn/mutalyzer/trunk@180 eb6bd6ab-9ccd-42b9-aceb-e2899b4a52f1
---
 src/wsgi.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/wsgi.py b/src/wsgi.py
index fe83e5a6..840fc341 100644
--- a/src/wsgi.py
+++ b/src/wsgi.py
@@ -1008,7 +1008,15 @@ class Uploader:
                     web.ctx.status = '413 Request entity too large'
                     return 'Upload limit exceeded.'
                 #if
-                if not i.bestandsveld == None and i.bestandsveld.file:
+                # Non-conforming clients (read: LOVD) might send the form
+                # request urlencoded (and not as the requested multipart/
+                # form-data). We try to support this anyway.
+                if web.ctx.env.get('CONTENT_TYPE', '') \
+                       == 'application/x-www-form-urlencoded' \
+                       and isinstance(i.bestandsveld, str):
+                    UD = R.uploadrecord(i.bestandsveld)
+                elif not i.bestandsveld == None and i.bestandsveld.file:
+                    # Todo: actually we should check if .file exists
                     UD = R.uploadrecord(i.bestandsveld.file.read())
                 else:
                     raise web.badrequest()
-- 
GitLab