Anonymous avatar Anonymous committed 2b0ca96 Draft

Added basic field transforms

Comments (0)

Files changed (1)


                 try: ret['absolute_uri'] = data.get_absolute_url()
                 except: pass
+            def _transform(data, transforms):
+                import pdb; pdb.set_trace()
+                if type(data) is list:
+                    new_list = []
+                    for _d in data:
+                        new_list.append(_transform(_d, transforms))
+                    return new_list
+                for name in transforms.keys():
+                    if name in data:
+                        if type(transforms[name]) is dict:
+                            data[name] = _transform(data[name],
+                                    transforms[name])
+                        else:
+                            data[transforms[name]] = data[name]
+                            del data[name]
+                return data
+            if hasattr(handler, 'name_transforms'):
+                name_transforms = getattr(handler, 'name_transforms')
+                ret = _transform(ret, name_transforms)
             return ret
         def _qs(data, fields=None):
     def render(self, request):
         return pickle.dumps(self.construct())
-Emitter.register('pickle', PickleEmitter, 'application/python-pickle')
 WARNING: Accepting arbitrary pickled data is a huge security concern.
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
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.