|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Method dispatcher wiki example problemTaking 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "cherrypy-users" group. To post to this group, send email to cherrypy-users@... To unsubscribe from this group, send email to cherrypy-users+unsubscribe@... For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Method dispatcher wiki example problemVoltron a écrit : > 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 You are mounting the application with cherrypy.tree.mount and you do provide the conf but then you override it with cherrypy.quickstart without providing the conf. Either: cherrypy.tree.mount(root, "/", conf) cherrypy.engine.start() cherrypy.engine.block() Or: cherrypy.quickstart(root, "/", conf) - Sylvain --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "cherrypy-users" group. To post to this group, send email to cherrypy-users@... To unsubscribe from this group, send email to cherrypy-users+unsubscribe@... For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |