configuring a response on a request

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

configuring a response on a request

matt Gerwen van
Hi,

I am very new to programming and cherrypy. 
So far I understand that a method of a class, which has been exposed, is a page handler ( =becomes a html page). How do I tell cherrypy to come back, response with page-x?
thanks in advance

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: configuring a response on a request

Michiel Overtoom

Hi Matt,

> On 2016-08-02, at 10:39, matt Gerwen van <[hidden email]> wrote:
>
> I understand that a method of a class, which has been exposed, is a page handler (=becomes a html page).

More or less. The method doesn't 'become' a page, but it is called by CherryPy and expected to return the content for the page.


> How do I tell cherrypy to come back, response with page-x?

I don't understand this question. What do you want to accomplish? What is a 'page-x'? My intuition says you want a redirect (possibly internal), but I'm not sure.

Greetings,

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: configuring a response on a request

Tim Roberts
In reply to this post by matt Gerwen van
matt Gerwen van wrote:
>
> I am very new to programming and cherrypy.
> So far I understand that a method of a class, which has been exposed,
> is a page handler ( =becomes a html page). How do I tell cherrypy to
> come back, response with page-x?

Part of this is understanding the flow of a web server.  Think about
things from a "flow" point of view, and perhaps it will make more sense.

So, you might have a login page, http://mysite/login, which displays a
login page, and say that a logged-in user has to go to a main.  When the
user responds, it's up to you to decide whether the <form> goes to your
"login" handler or to your "main" handler for validation.  Usually, I
want the response to page "x" to be handled by the page "x" handler.

But in that case, if the "login" handler approves the login, then you
need to show the "main" page.  In my view, the most expedient method of
doing that is to send a redirect.  Your login pages raises an
HTTPRedirect exception with the next URL.  The browser, in response,
will make a new request.  So:

    def login(self, user, pass):
        if validate(user,pass):
            cherrypy.session[xxx] = user
            raise cherrypy.HTTPRedirect('/main')
        else:
            tmplt.error = "Invalid Login"
        Go display template

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Loading...