[Featureserver] [PATCH] handle multipart POSTs

Dan Lipsitt danlipsitt at gmail.com
Wed Jan 16 15:09:59 EST 2008


Below is a patch that fixes multipart posts. It looks for attached
files and adds them to the post_data. I don't know how it will perform
with the PUT method, so it may need some changes to handle that case.

I also have a working partial implementation of a GML Service, if
anybody is interested.

Dan


===================================================================
--- FeatureServer/Server.py	(revision 423)
+++ FeatureServer/Server.py	(working copy)
@@ -215,11 +217,16 @@
         fields = {}

         request_method = environ['REQUEST_METHOD']
-
-        if request_method != "GET" and request_method != "DELETE":
+
+        if request_method != 'POST':
+            fields = parse_formvars(environ)
+        elif environ['CONTENT_TYPE'].startswith('multipart'):
+            fields = parse_formvars(environ)
+            files = [field for field in fields.itervalues() if
hasattr(field, "file")]
+            if len(files) > 0:
+                post_data = files[0].value
+        else:
             post_data =
environ['wsgi.input'].read(int(environ['CONTENT_LENGTH']))
-        else:
-            fields = parse_formvars(environ)

         if "PATH_INFO" in environ:
             path_info = environ["PATH_INFO"]



More information about the Featureserver mailing list