Jesper Nøhr avatar Jesper Nøhr committed c9fe89f

fixing errors caused by 9ba4a23474c1

Comments (0)

Files changed (2)

piston/emitters.py

             elif isinstance(thing, decimal.Decimal):
                 ret = str(thing)
             elif isinstance(thing, Model):
-                ret = _model(thing, fields=fields)
+                ret = _model(thing, fields)
             elif isinstance(thing, HttpResponse):
                 raise HttpStatusCode(thing)
             elif inspect.isfunction(thing):
             """
             return [ _any(v, fields) for v in data ]
 
-        def _dict(data, fields):
+        def _dict(data, fields=()):
             """
             Dictionaries.
             """

piston/resource.py

         except Exception, e:
             result = self.error_handler(e, request, meth, em_format)
 
-
         try:
             emitter, ct = Emitter.get(em_format)
+            fields = handler.fields
+
+            if hasattr(handler, 'list_fields') and (isinstance(result, list) or
+                                                    isinstance(result, QuerySet)):
+                fields = handler.list_fields
         except ValueError:
             result = rc.BAD_REQUEST
             result.content = "Invalid output format specified '%s'." % em_format
             return result
 
-        try:
-            result, fields = result
-        except ValueError:
-            fields = handler.fields
-            if hasattr(handler, 'list_fields') and (
-                    isinstance(result, list) or isinstance(result, QuerySet)):
-                fields = handler.list_fields
-
         status_code = 200
 
         # If we're looking at a response object which contains non-string
             # to convert the content into a string which we don't want. 
             # when _is_string is False _container is the raw data
             result = result._container
-            
+     
         srl = emitter(result, typemapper, handler, fields, anonymous)
 
         try:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.