chadwhitacre / mongs

A nice web-based MongoDB data browser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Internal server error when datetime in field request

jaraco opened this issue · comments

Requesting a document with a path like /localhost/db/coll/58950a0793829ed312d83239/versions.json fails because there are date fields that are unserializable.

Traceback (most recent call last):
  File "/app/.heroku/venv/lib/python2.7/site-packages/algorithm.py", line 288, in run
    new_state = function(**deps.as_kwargs)
  File "/app/.heroku/venv/lib/python2.7/site-packages/aspen/algorithms/website.py", line 115, in get_response_for_resource
    return {'response': resource.respond(state)}
  File "/app/.heroku/venv/lib/python2.7/site-packages/aspen/http/resource.py", line 59, in respond
    content_type, body = super(Dynamic, self).respond(accept, state)
  File "/app/.heroku/venv/lib/python2.7/site-packages/aspen/simplates/__init__.py", line 169, in respond
    exec(self.pages[1], context)
  File "/app/www/%server/%database/%collection/%filter/%value.json.spt", line 11, in <module>
    response.body = json.dumps(value)
  File "/usr/lib/python2.7/json/__init__.py", line 243, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python2.7/json/encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: datetime.datetime(2017, 2, 3, 22, 53, 59, 83000) is not JSON serializable
500 Internal Server Error            /localhost/db/coll/58950a0793829ed312d83239/versions.json ...s/aspen/www/error.spt