Re: [web2py] Re: Redirecting to a URL, but with changed html

2011-12-14 Thread pbreit
So test() is going to have to grab the cookie and then include it with the urlopen(). Seems kind of weird.

[web2py] Re: Redirecting to a URL, but with changed html

2011-12-14 Thread peter
Well this has all been a good education to me about how cookies work. I had not previously thought too hard about cookies, but just imagined that somehow the website communicated with the browser behind the scenes to get the cookie content when it needed it. From the responses and a little

[web2py] Re: Redirecting to a URL, but with changed html

2011-12-13 Thread peter
Thanks for your answers. I guess editing the html and replacing the relative URLs with absolute ones is not too bad. The problem I am left with is this: Can one 'call' a URL from web2py as if the URL were called from the users browser?, but capture the html result? I imagine the answer to this

[web2py] Re: Redirecting to a URL, but with changed html

2011-12-13 Thread Anthony
On Tuesday, December 13, 2011 4:15:22 AM UTC-5, peter wrote: Thanks for your answers. I guess editing the html and replacing the relative URLs with absolute ones is not too bad. The problem I am left with is this: Can one 'call' a URL from web2py as if the URL were called from the users

[web2py] Re: Redirecting to a URL, but with changed html

2011-12-13 Thread peter
Here is a simple example of what I mean: If I type http://127.0.0.1:8000/admin/default/site at my browser when I am logged in, I get the installed applications page. However if I do it by calling the test routine below def test(): import urllib

Re: [web2py] Re: Redirecting to a URL, but with changed html

2011-12-13 Thread Jonathan Lundell
On Dec 13, 2011, at 11:09 AM, peter wrote: Here is a simple example of what I mean: If I type http://127.0.0.1:8000/admin/default/site at my browser when I am logged in, I get the installed applications page. However if I do it by calling the test routine below def test():

[web2py] Re: Redirecting to a URL, but with changed html

2011-12-13 Thread Anthony
On Tuesday, December 13, 2011 2:09:31 PM UTC-5, peter wrote: def test(): import urllib url=http://127.0.0.1:8000/admin/default/site; f = urllib.urlopen(url) s = f.read() return s I have to login again even though I am logged in on my computer. So

[web2py] Re: Redirecting to a URL, but with changed html

2011-12-13 Thread peter
So in my example above. How does web2py's admin know I am logged in? Does it do this by accessing a cookie on my computer, if so how does it do that behind the scenes? Could urllib2.urlopen really handle this? Thanks Peter On Dec 13, 7:27 pm, Anthony abasta...@gmail.com wrote: On Tuesday,

Re: [web2py] Re: Redirecting to a URL, but with changed html

2011-12-13 Thread Jonathan Lundell
On Dec 13, 2011, at 12:28 PM, peter wrote: So in my example above. How does web2py's admin know I am logged in? Does it do this by accessing a cookie on my computer, if so how does it do that behind the scenes? Could urllib2.urlopen really handle this? Ordinarily it knows you're logged in

Re: [web2py] Re: Redirecting to a URL, but with changed html

2011-12-13 Thread Anthony
On Tuesday, December 13, 2011 3:45:34 PM UTC-5, Jonathan Lundell wrote: On Dec 13, 2011, at 12:28 PM, peter wrote: So in my example above. How does web2py's admin know I am logged in? Does it do this by accessing a cookie on my computer, if so how does it do that behind the scenes? Could

Re: [web2py] Re: Redirecting to a URL, but with changed html

2011-12-13 Thread Jonathan Lundell
On Dec 13, 2011, at 12:54 PM, Anthony wrote: On Tuesday, December 13, 2011 3:45:34 PM UTC-5, Jonathan Lundell wrote: On Dec 13, 2011, at 12:28 PM, peter wrote: So in my example above. How does web2py's admin know I am logged in? Does it do this by accessing a cookie on my computer, if so

Re: [web2py] Re: Redirecting to a URL, but with changed html

2011-12-13 Thread Anthony
I think it's easier than that, if you're already logged in, which I think is the case here. The session cookie is already in request.cookies. It sounded like he wanted to do this with external websites, not necessarily the current app (or even a web2py app).

Re: [web2py] Re: Redirecting to a URL, but with changed html

2011-12-13 Thread Jonathan Lundell
On Dec 13, 2011, at 1:40 PM, Anthony wrote: I think it's easier than that, if you're already logged in, which I think is the case here. The session cookie is already in request.cookies. It sounded like he wanted to do this with external websites, not necessarily the current app (or even a

Re: [web2py] Re: Redirecting to a URL, but with changed html

2011-12-13 Thread pbreit
Yeah, he's going to need to first script a login so he can grab and store the cookie which he is then going to need to present on each urllib.urlopen(). Being logged in on your browser is not going to help since your browser and your web2py code are totally separate. He could possibly make it

Re: [web2py] Re: Redirecting to a URL, but with changed html

2011-12-13 Thread Jonathan Lundell
On Dec 13, 2011, at 5:22 PM, pbreit wrote: Yeah, he's going to need to first script a login so he can grab and store the cookie which he is then going to need to present on each urllib.urlopen(). Being logged in on your browser is not going to help since your browser and your web2py code

Re: [web2py] Re: Redirecting to a URL, but with changed html

2011-12-13 Thread pbreit
Oh, I see. If the person logs in to a web2py app and then hits a page which is going to do the urlopen that calls the same app, then I suppose you could grab the cookie and send it along. Is that really what id being contemplated? I wonder if a LOAD() would suffice?

Re: [web2py] Re: Redirecting to a URL, but with changed html

2011-12-13 Thread Anthony
On Tuesday, December 13, 2011 8:36:47 PM UTC-5, pbreit wrote: Oh, I see. If the person logs in to a web2py app and then hits a page which is going to do the urlopen that calls the same app, then I suppose you could grab the cookie and send it along. Is that really what id being

Re: [web2py] Re: Redirecting to a URL, but with changed html

2011-12-13 Thread Jonathan Lundell
On Dec 13, 2011, at 6:20 PM, Anthony wrote: The original example was for url of some web page, which I assume is not in the same app (or necessarily even a web2py app at all). If it's in the same app, or any web2py app under your control, there should be better ways to return the output of

[web2py] Re: Redirecting to a URL, but with changed html

2011-12-12 Thread Anthony
I guess that's not technically a redirect -- it's actually copying the other page and delivering the copy. What do you mean it's no longer connected to the session? The difficulty with copying a web page and delivering the copy is that it might contain some relative URL references (links as

[web2py] Re: Redirecting to a URL, but with changed html

2011-12-12 Thread Anthony
You would have to rewrite the URLs to make them absolute (including URLs within any static files linked in the page) Correction -- you probably don't have to worry about relative URLs within linked CSS files because they will be loaded relative to the CSS file URL (so only that URL needs

[web2py] Re: Redirecting to a URL, but with changed html

2011-12-12 Thread Constantine Vasil
Spend all week struggling with the same. Basically you have to use browsers' window.location.replace and initialize the location via Python from your function. Let say you are here: http://www.mycoolapp.com/old_location in the html you place the JavaScript at the bottom before /body:

[web2py] Re: Redirecting to a URL, but with changed html

2011-12-12 Thread Anthony
web2py redirect issues a standard http redirect, so the address will change in the browser address bar. I believe you were using jQuery Mobile and Ajax, which apparently introduces some complications (not specific to web2py). For a regular application, a standard redirect should work fine. In

[web2py] Re: Redirecting to a URL, but with changed html

2011-12-12 Thread Constantine Vasil
yes, redirect is little tricky ;) my solution is for ajax.