Taking the example from the wiki:
import cherrypy
class Root():
exposed = True
def __init__(self, *things):
self.things = list(things)
def GET(self):
return repr(self.things)
def POST(self, thing):
self.things.append(thing)
root = Root(1, 2, 3)
d = cherrypy.dispatch.MethodDispatcher()
conf = {'/': {'request.dispatch': d}}
cherrypy.tree.mount(root, "/", conf)
cherrypy.server.socket_port=8081
cherrypy.quickstart(root)
This fails with a traceback:
Traceback (most recent call last):
File "C:\Python26\lib\site-packages\cherrypy\_cprequest.py", line
606, in respond
cherrypy.response.body = self.handler()
File "C:\Python26\lib\site-packages\cherrypy\_cpdispatch.py", line
25, in __call__
return self.callable(*self.args, **self.kwargs)
AttributeError: Root instance has no __call__ method
Can someone tell me what I have done wrong? Thanks