need help using cherrypy

View: New views
4 Messages — Rating Filter:   Alert me  

need help using cherrypy

by Madhusudhan sunkara :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

--~--~---------~--~----~------------~-------~--~----~
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: need help using cherrypy

by Madhusudhan sunkara :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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

On Mon, Nov 9, 2009 at 12:32 AM, Madhusudhan sunkara <madhusudhan.sunkara@...> wrote:
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



--
Madhu Sudhan Sunkara

--~--~---------~--~----~------------~-------~--~----~
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: need help using cherrypy

by Jeff H-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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...@...>
wrote:

> 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
>
> On Mon, Nov 9, 2009 at 12:32 AM, Madhusudhan sunkara <
>
>
>
> madhusudhan.sunk...@...> wrote:
> > 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
>
> --
> Madhu Sudhan Sunkara
--~--~---------~--~----~------------~-------~--~----~
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: need help using cherrypy

by Madhusudhan sunkara :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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


On Tue, Nov 10, 2009 at 7:44 AM, dundeemt <dundeemt@...> wrote:

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...@...>
wrote:
> 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
>
> On Mon, Nov 9, 2009 at 12:32 AM, Madhusudhan sunkara <
>
>
>
> madhusudhan.sunk...@...> wrote:
> > 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
>
> --
> Madhu Sudhan Sunkara




--
Madhu Sudhan Sunkara

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---