Commits

imbolc committed 1dd5aa0

datetime json codec

  • Participants
  • Parent commits 3f2f47b

Comments (0)

Files changed (2)

File pysi/template.py

 # -*- coding: utf-8 -*-
 import os
+from datetime import datetime
 
 import wsgi
 from config import cfg
         from django.utils import simplejson as json
     except ImportError:
         raise ImportError('Json module not found')
-    return json.dumps
+    kw = {'default': json_default_handler}
+    if cfg.DEBUG:
+        kw['indent'] = 2
+    return lambda obj: json.dumps(obj, **kw)
+
+def json_default_handler(obj):
+    return obj.isoformat() if isinstance(obj, datetime) else None
+
 
 @cached_function
 def _env():
 import os
 from setuptools import setup
 
-VERSION = '0.13.0'
+VERSION = '0.14.0'
 PACKAGE = 'pysi'
 
 if __name__ == '__main__':