need help using cherrypy

5 views
Skip to first unread message

Madhusudhan sunkara

unread,
Nov 8, 2009, 2:02:19 PM11/8/09
to cherryp...@googlegroups.com
Hi All,

i know this is very basic usage, i am a new user of cherrypy.
i have a problem like below

def index(self):
        return """<form method='POST' action='/form'>
        type something <input type='text' name='inp'>
        <input type='submit'>
        </form>"""
    index.exposed=True

    def form(self,inp=None,**kw):
        return 'you typed : "%s"'%(inp,)
    form.exposed = True

both methods are defined in simple class , when data is submitted it is not received in form method.
i am getting None (the default value)

is there anything i am missing ?

--
Madhu

Madhusudhan sunkara

unread,
Nov 8, 2009, 2:15:14 PM11/8/09
to cherryp...@googlegroups.com

i am using 3.1.2 , even example is not working for me
:/usr/lib/python2.5/site-packages/cherrypy/tutorial/tut03_get_and_post.py
---------------------------------------------------------------------------
 def index(self):
        # Ask for the user's name.
        return '''
            <form action="greetUser" method="GET">
            What is your name?
            <input type="text" name="name" />
            <input type="submit" />
            </form>'''
    index.exposed = True
   
    def greetUser(self, name = None):
        # CherryPy passes all GET and POST variables as method parameters.
        # It doesn't make a difference where the variables come from, how
        # large their contents are, and so on.
        #
        # You can define default parameter values as usual. In this
        # example, the "name" parameter defaults to None so we can check
        # if a name was actually specified.
       
        if name:
            # Greet the user!
            return "Hey %s, what's up?" % name
        else:
            if name is None:
                # No name was specified
                return 'Please enter your name <a href="./">here</a>.'
            else:
                return 'No, really, enter your name <a href="./">here</a>.'
    greetUser.exposed = True
-----------------------------------------------------

is there something wrong with this version?
please help
--
Madhu Sudhan Sunkara

dundeemt

unread,
Nov 9, 2009, 9:14:47 PM11/9/09
to cherrypy-users
So, if you start the app with

python /usr/lib/python2.5/site-packages/cherrypy/tutorial/
tut03_get_and_post.py
and then go to http://localhost:8080/, what do you see in the debug
window?

When you enter Madhusudhan in the text box and click "Sumit Query",
what url do you land at?
Is it? http://localhost:8080/greetUser?name=Madhusudhan

In the debug window you should see something like:
127.0.0.1 - - [09/Nov/2009:20:08:29] "GET / HTTP/1.1" 200 184 ""
"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.15) Gecko/2009102815
Ubuntu/9.04 (jaunty) Firefox/3.0.15"
127.0.0.1 - - [09/Nov/2009:20:08:34] "GET /greetUser?name=jeff HTTP/
1.1" 200 20 "http://localhost:8080/" "Mozilla/5.0 (X11; U; Linux i686;
en-US; rv:1.9.0.15) Gecko/2009102815 Ubuntu/9.04 (jaunty) Firefox/
3.0.15"

I am successfully running the example here.

-Jeff

On Nov 8, 1:15 pm, Madhusudhan sunkara <madhusudhan.sunk...@gmail.com>
wrote:

Madhusudhan sunkara

unread,
Nov 9, 2009, 11:55:28 PM11/9/09
to cherryp...@googlegroups.com
Thanks Jeff,

i am able to run the example or similar files in other machines. in the end it turned out to be browser charset,  once i set it to Western ISO-8859-1 everything started working fine.

so, is it good idea to have accept-charset attribute in form? does it make a difference

Thanks
--
Madhu Sudhan Sunkara
Reply all
Reply to author
Forward
0 new messages