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):
cherrypy.session[xxx] = user
tmplt.error = "Invalid Login"
Go display template