Thanks for adding json-py 3.4!  Very nice.  I'm still running into a
problem though...
I have a simple table of users delcared like so:

class User(SQLObject):
    creationDate = DateTimeCol()
    modificationDate = DateTimeCol()
    username = StringCol(length=40,alternateID=True)
    password = StringCol(length=40)
    contacts = MultipleJoin('Contact')
    exposures = MultipleJoin('Exposure')

I have a method in controllers.py declared like so:

    @turbogears.expose(html="cms.templates.listUser")
    def listUser(self):
        users = [user for user in User.select(orderBy=User.q.id)]
        return dict(users=users)

If I try to hit the URL: http://localhost:8080/listUser?tg_format=json
I get this (this is part of it anyway):

        <h2>500 Internal error</h2>
        <p>Server got itself in trouble</p>
        <pre id="traceback">Traceback (most recent call last):
  File
"c:\python24\lib\site-packages\CherryPy-2.1.0-py2.4.egg\cherrypy\_cphttptools.py",
line 271, in run
    main()
  File
"c:\python24\lib\site-packages\CherryPy-2.1.0-py2.4.egg\cherrypy\_cphttptools.py",
line 502, in main
    body = page_handler(*args, **cherrypy.request.paramMap)
  File
"c:\python24\lib\site-packages\TurboGears-0.8a5-py2.4.egg\turbogears\controllers.py",
line 122, in newfunc
    return controllers._process_output(tg_format, output, html)
  File
"c:\python24\lib\site-packages\TurboGears-0.8a5-py2.4.egg\turbogears\controllers.py",
line 38, in _process_output
    output = view.render(output, tg_format, template=template)
  File
"c:\python24\lib\site-packages\TurboGears-0.8a5-py2.4.egg\turbogears\view.py",
line 91, in render
    return json.write(info)
  File "c:\python24\lib\site-packages\json_py-3.4-py2.4.egg\json.py",
line 307, in write
  File "c:\python24\lib\site-packages\json_py-3.4-py2.4.egg\json.py",
line 255, in write
  File "c:\python24\lib\site-packages\json_py-3.4-py2.4.egg\json.py",
line 266, in _write
  File "c:\python24\lib\site-packages\json_py-3.4-py2.4.egg\json.py",
line 275, in _write
  File "c:\python24\lib\site-packages\json_py-3.4-py2.4.egg\json.py",
line 304, in _write
WriteException: Cannot write in JSON: &lt;User 1
creationDate='datetime.datetime...)'
modificationDate='datetime.datetime...)' username='test'
password='test'&gt;
</pre>
    <div id="poweredBy">
    <span>Powered by <a href="http://www.cherrypy.org";>Cherrypy
2.1.0</a></span>
    </div>

Is it the DateTimeCol 's that are giving JSON grief now?  I really
appreciate your help.  Thanks,

Evan

Kevin Dangoor wrote:
> I've uploaded a json-py 3.4 egg. You can get it like this:
>
> easy_install -f http://www.turbogears.org/download/index.html json-py
> 
> Let me know if you run into any problem...
> 
> Kevin

Reply via email to