Christoph Zwerschke wrote:
> Alexandre da Silva schrieb:
>   
>> Em Seg, 2008-03-31 às 17:02 +0200, Christoph Zwerschke escreveu:
>>     
>>> Thanks, I totally forgot about that. Actually I think the login 
>>> mechanism uses the same idea. I'll check out how that works.
>>>       
>> login mechanism seems to save the url entered before authentication,
>> than after login redirect the user to that url.
>>     
>
> Yes, but is also checks cherrypy.request.path to find the previous_url.
>
> Jim, just to make sure, was your idea to use cherrypy.request.path or to 
> use the HTTP Referer header? In the edit controller, looking in 
> cherrypy.request.path for the previous URL will be too late, you would 
> need the Referer which may not be supported by all clients. Or is the 
> idea to add cherrypy.request.path to the edit link or to let the grid 
> controller redirect to the edit controller?
>
> I think we need to put a working example in the Wiki ;-)
>
> -- Christoph
>
> >
>   
Ah, yes.  It would appear that I didn't dig deep enough into my code.  
My code is pasted here:  http://pastebin.com/m2f3b4c1a

I am using the cherrypy.request.path in my code to get the 'current' 
url.  Later in the code I use cherrypy.request.headers['Referer'] to get 
the URL of the referring page.  Sorry for the misleading post earlier. 

I keep this in a utility module that I can call to get the url of the 
referring page.  As you will see, this isn't the cleanest code in the 
world.  I seem to recall grabbing the URL parsing code off the web 
somewhere and futzing with it until I got it to work for me. 

A couple other things that I do with this.  You can see that I save the 
referring URL in a cookie.  This is in case you reload the page that you 
are on, or if a validator threw an error and your page was redisplayed.  
In this case, you want to keep your referrer as the 'previous' previous 
page.  I append a parameter on the URL string to tell this method 
whether or not it should use the value in the cookie if the cookie 
exists.  This is the uc_ parameter.

Also, I maintain a dictionary of pages that should not be considered a 
'referring' page.  This is used when a maintenance routine takes you 
through multiple pages before taking you back to your starting point.  
In this case, the second 'edit' page would not want the first 'edit' 
page to be considered it's referring page.  In this instance, I force 
the second 'edit' pages referrer to be the same as that of the first page.

Also, note that I have the following import at the top of this module:

import cherrypy as http

Let me know if you have any more questions and I'll do the best I can to 
answer them.  Or, this may be more information than you were looking for 
in the first place.  But, this works well for me to manage how I know 
where I'm coming from and getting back to that place.  Not ideal by any 
means, but workable for now.

    -Jim

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to