title: Unable to serialize datetime.datetime object in dictionary to JSON using python and trac
body: <p>I have a list of dictionaries (each dictionary representing 1 record of an SQL query) which I am trying to serialize as JSON. There are several datetime.date and datetime.datetime objects in these dictionaries which are proving difficult to serialize. Initially, the error message is:</p>
  
  <pre><code>TypeError: datetime.date(2012, 5, 23) is not JSON serializable
  </code></pre>
  
  <p>After adding a handler to the json.dumps call the error message is:</p>
  
  <pre><code>TypeError: date_handler() takes exactly 1 argument (2 given)
  </code></pre>
  
  <p>date_handler looks like this:</p>
  
  <pre><code>    def date_handler(obj):
          return obj.isoformat() if hasattr(obj, 'isoformat') else obj
  </code></pre>
  
  <p>I'm running this as part of a Trac plugin however I think this is just an isolated python issue but have no idea what to do to sort it - does anyone have any ideas?</p>