aparo/pyes — pull request #158 by barnybug (2012-01-26 09:39:22+00:00)
Title: Handle datetimes before 1900

Created a patch to fix an issue in the serializing:

>>> import pyes, datetime
>>> es = pyes.ES()
>>> es.index({'created': datetime.datetime(1863, 2, 1) }, 'test-index', 'test', '123')
Traceback (most recent call last):
File "", line 1, in
File "/home/barnaby/git/pyes/pyes/es.py", line 990, in index
return self._send_request(request_method, path, doc, querystring_args)
File "/home/barnaby/git/pyes/pyes/es.py", line 405, in _send_request
body = json.dumps(body, cls=self.encoder)
File "/usr/lib/python2.7/dist-packages/simplejson/__init__.py", line 269, in dumps
use_decimal=use_decimal, **kw).encode(obj)
File "/usr/lib/python2.7/dist-packages/simplejson/encoder.py", line 216, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python2.7/dist-packages/simplejson/encoder.py", line 284, in iterencode
return _iterencode(o, 0)
File "/home/barnaby/git/pyes/pyes/es.py", line 168, in default
return value.strftime("%Y-%m-%dT%H:%M:%S")
ValueError: year=1863 is before 1900; the datetime strftime() methods require year >= 1900
>>>