Commits

Ian George  committed 20cb1cb

utils.py changes to (hopefully) sort out some odd 400 errors. emitters.py changed to make sure the right sets of fields were being used.

  • Participants
  • Parent commits 4fe8af1

Comments (0)

Files changed (2)

File piston/emitters.py

             if handler or fields:
                 v = lambda f: getattr(data, f.attname)
 
-                if handler:
-                    fields = getattr(handler, 'fields')    
-                
-                if not fields or hasattr(handler, 'fields'):
+                if fields:
+                    get_fields = set(fields)
+                else:
+                    if handler:
+                        fields = getattr(handler, 'fields')    
+
                     """
                     Fields was not specified, try to find teh correct
                     version in the typemapper we were sent.
                                 if exclude.match(field):
                                     get_fields.discard(field)
 
-                else:
-                    get_fields = set(fields)
-
                 met_fields = self.method_fields(handler, get_fields)
 
                 for f in data._meta.local_fields + data._meta.virtual_fields:

File piston/utils.py

         """
         for loadee, mimes in Mimer.TYPES.iteritems():
             for mime in mimes:
-                if ctype.startswith(mime):
+                if ctype == mime:
                     return loadee
                     
     def content_type(self):
 
         ctype = self.request.META.get('CONTENT_TYPE', type_formencoded)
         
-        if type_formencoded in ctype:
+        ctype = ctype.split(';')[0]
+
+        if type_formencoded == ctype:
             return None
         
         return ctype