Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Method dispatcher wiki example problem
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Voltron  
View profile  
 More options Oct 31, 4:22 am
From: Voltron <nhy...@googlemail.com>
Date: Sat, 31 Oct 2009 01:22:06 -0700 (PDT)
Local: Sat, Oct 31 2009 4:22 am
Subject: Method dispatcher wiki example problem
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


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sylvain Hellegouarch  
View profile  
 More options Oct 31, 5:07 am
From: Sylvain Hellegouarch <s...@defuze.org>
Date: Sat, 31 Oct 2009 10:07:03 +0100
Local: Sat, Oct 31 2009 5:07 am
Subject: Re: [cherrypy-users] Method dispatcher wiki example problem
Voltron a écrit :

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


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google