|
List Info
Thread: redirect vs return
|
|
| redirect vs return |

|
2006-03-15 19:02:02 |
pytrade wrote:
> No I would want something like:
>
> raise cherrypy.HTTPRedirectInternal(url)
>
> Where the exception would discard all my custom
decorators and restart
> a new request without having to leave the current
server process.
There is an existing cherrypy.InternalRedirect. It doesn't
completely
restart the request; however, it will discover and call the
new page
handler.
> One question I have is that does using the current
<raise
> cherrypy.HTTPRedirect(url)> return the request to
the browser
> requesting the client to load a new url or is it smart
enought to
> internally redirect to the new url.
An HTTPRedirect is smart enough to *not* do that ;) since
the semantic
is quite different. An HTTP redirect is used only when you
*want* to
notify the user-agent that a resource is somewhere else.
Otherwise, use
InternalRedirect, or (since you're already using a
general-purpose
programming language) just call the next function.
Robert Brewer
System Architect
Amor Ministries
fumanchu amor.org
--~--~---------~--~----~------------~-------~--~----~
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 googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|
|
| redirect vs return |

|
2006-03-15 20:35:42 |
I still don't follow:
expose
buildUI
dbTransaction
convertargs
def function1(var1, var2)
raise cherrypy.HTTPRedirectInternal(urltToFunction2)
expose
buildUI
dbTransaction
convertargs
def function2(var1, var2)
return content
>>An HTTPRedirect is smart enough to *not* do that ;)
since the semantic
>>is quite different. An HTTP redirect is used only
when you *want* to
>>notify the user-agent that a resource is somewhere
else. Otherwise, use
You seem to be saying two contradicting things. One is that
raising an
HTTPRedirect is smart enough not to send it back to the
browser and
just calls the function2 in the above example resetting the
request
stack. but then you say that you should not use HTTPRedirect
In the above example I want to end up calling function2 from
function1
(and reset the request stack when I call function2). Is this
possible
and how would I do it?
Thanks,
VJ
--~--~---------~--~----~------------~-------~--~----~
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 googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|
|
| redirect vs return |

|
2006-03-15 21:21:38 |
pytrade wrote:
> I still don't follow:
[snip decorated functions]
Let's back up for a minute.
pytrade wrote:
> I've been using the following for redirects:
>
> raise cherrypy.HTTPRedirect(url)
>
> It however seems rather inefficient (if my
understanding is correct).
> Is there a way to forward to a different url without
having to do
> another round turn with the browser.
CherryPy's HTTPRedirect exception does a *real* HTTP
redirect, which
does notify the browser (UA) that the document is elsewhere.
Most
browsers will then automatically navigate to the URI that
the server
notified it of. It really isn't that inefficient, and is
part of the
HTTP spec.
As Robert mentioned, CherryPy does offer an InternalRedirect
exception,
or you can simply return the results of another callable
directly.
pytrade wrote:
> I want to end up calling function2 from function1
> (and reset the request stack when I call function2). Is
this possible
> and how would I do it?
I am not sure what you mean by "reset the request
stack". If you mean
undo all the stuff you did on the way to the inner callable
in your
decorator wrap, that is up to you. You should make some
sort of
reset_request_stack() function that means what you want it
to mean
HTH,
Christian
http://www.dowski.com
--~--~---------~--~----~------------~-------~--~----~
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 googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|
|
| redirect vs return |

|
2006-03-15 21:43:21 |
Thanks that makes sense.
>>An HTTPRedirect is smart enough to *not* do that ;)
since the semantic
>>is quite different. An HTTP redirect is used only
when you *want* to
>>notify the user-agent that a resource is somewhere
else. Otherwise, use
Isn't that what
raise cherrypy.InternalRedirect("/function2")
does? when I do an internal redirect I would like the
decorater
hierarchy to be reset and the new function called with it's
own
decorator hierarchy.
--~--~---------~--~----~------------~-------~--~----~
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 googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|
|
| redirect vs return |

|
2006-03-15 21:52:19 |
Christian Wyglendowski wrote:
[snip a bunch of drivel]
Ok, forget what I said. Listen to Robert
Christian
http://www.dowski.com
--~--~---------~--~----~------------~-------~--~----~
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 googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|
|
[1-5]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|