开发者

cherrypy jsondecoder not found

I tried this example:

import cherrypy

class Root(object):
    @cherrypy.expose
    @cherrypy.tools.json_out()
    def getrange(self, limit=4):
        return list(range(int(limit)))

cherrypy.quickstart(Root())

when I run this, I get:

开发者_如何学编程
Traceback (most recent call last):
  File "D:/Dev/BaronPOS/baronpos/Server/tester.py", line 1, in <module>
    import cherrypy
  File "C:\Python27\lib\site-packages\cherrypy\__init__.py", line 62, in <module>
    from cherrypy._cpcompat import urljoin as _urljoin, urlencode as _urlencode
  File "C:\Python27\lib\site-packages\cherrypy\_cpcompat.py", line 244, in <module>
    json_decode = json.JSONDecoder().decode
AttributeError: 'module' object has no attribute 'JSONDecoder'

and I have absolutely no idea why. I have checked if the module is present and the class and both are. Please help!


OK, I figured it out.

I was using SimpleJSONRPCServer previously (http://www.freenet.org.nz/dojo/pyjson/) but decided to move to a more flexible REST compatible architecture.

Apparantly I left an artifact called json.py, which was causing this...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜