Jesper Nøhr  committed 7042cd3

bit of tweaking to content-type detection and default create method

  • Participants
  • Parent commits 6c26142

Comments (0)

Files changed (3)

File piston/

     def method_fields(self, data, fields):
         if not data:
-            return data
+            return { }
         has = dir(data)
         ret = dict()

File piston/

             inst = self.model(**attrs)
             return inst
+        except self.model.MultipleObjectsReturned:
+            return rc.DUPLICATE_ENTRY
     def update(self, request, *args, **kwargs):
         # TODO: This doesn't work automatically yet.

File piston/

                 return loadee
     def content_type(self):
-        return self.request.META.get('CONTENT_TYPE')
+        return self.request.META.get('CONTENT_TYPE', None)
     def translate(self):
         None for multipart form data (what your browser sends.)
         ctype = self.content_type()
+        self.request.content_type = ctype
         if not self.is_multipart() and ctype:
             loadee = self.loader_for_type(ctype)
-                self.request.content_type = ctype
        = loadee(self.request.raw_post_data)
                 # Reset both POST and PUT from request, as its