Commits

takanao ENDOH  committed c2938a2

Refactored API.

  • Participants
  • Parent commits 3cd1539

Comments (0)

Files changed (1)

File 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>