Jesper Nøhr avatar Jesper Nøhr committed d6e2114

breaking some behavior here, but need it for now

Comments (0)

Files changed (1)

piston/emitters.py

 
         Returns `dict`.
         """
-        def _any(thing, fields=()):
+        def _any(thing, fields=None):
             """
             Dispatch, all types are routed through here.
             """
             ret = None
 
             if isinstance(thing, QuerySet):
-                ret = _qs(thing, fields=fields)
+                ret = _qs(thing, fields)
             elif isinstance(thing, (tuple, list, set)):
-                ret = _list(thing, fields=fields)
+                ret = _list(thing, fields)
             elif isinstance(thing, dict):
                 ret = _dict(thing, fields)
             elif isinstance(thing, decimal.Decimal):
             """
             return _any(getattr(data, field.name))
 
-        def _related(data, fields=()):
+        def _related(data, fields=None):
             """
             Foreign keys.
             """
             return [ _model(m, fields) for m in data.iterator() ]
 
-        def _m2m(data, field, fields=()):
+        def _m2m(data, field, fields=None):
             """
             Many to many (re-route to `_model`.)
             """
             return [ _model(m, fields) for m in getattr(data, field.name).iterator() ]
 
-        def _model(data, fields=()):
+        def _model(data, fields=None):
             """
             Models. Will respect the `fields` and/or
             `exclude` on the handler (see `typemapper`.)
             if handler or fields:
                 v = lambda f: getattr(data, f.attname)
 
-                if not fields:
+                if handler:
+                    fields = getattr(handler, 'fields')    
+                
+                if not fields or hasattr(handler, 'fields'):
                     """
                     Fields was not specified, try to find teh correct
                     version in the typemapper we were sent.
 
             return ret
 
-        def _qs(data, fields=()):
+        def _qs(data, fields=None):
             """
             Querysets.
             """
             return [ _any(v, fields) for v in data ]
 
-        def _list(data, fields=()):
+        def _list(data, fields=None):
             """
             Lists.
             """
             return [ _any(v, fields) for v in data ]
 
-        def _dict(data, fields=()):
+        def _dict(data, fields=None):
             """
             Dictionaries.
             """
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.