takanao ENDOH avatar takanao ENDOH committed c2938a2

Refactored API.

Comments (0)

Files changed (1)

monologista/api/views.py

         return __func
     return _func
 
-def dumps_json(json):
+def dumps_json(data):
     options = dict(
         ensure_ascii = False,
         cls = DjangoJSONEncoder,
     )
     if settings.DEBUG:
         options.update(indent=2)
-    return simplejson.dumps(json, **options)
+    return simplejson.dumps(data, **options)
+
+def dumps_xml(data):
+    # TODO delete メッセージXMLシリアライザの作成
+    raise NotImplementedError
+
+def dump(data, format='json'):
+    dumper = dict(
+        json = dumps_json,
+        xml = dumps_xml,
+    ).get(format)
+    if dumper is None:
+        return "Not supported format."
+    return dumper(data)
 
 def get_monology_xml(monology):
     # <protected>%s</protected>
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.