[Zope] Help with session data and redirects

Brad Powell Brad.Powell@conocophillips.com
Tue, 15 Apr 2003 11:36:23 -0500


This is a multipart message in MIME format.
------=_NextPartTM-000-ea45a06c-f9fc-40c6-a725-4dd18633cc77
Content-Type: multipart/alternative; 
	boundary="=_alternative 005B384E86256D09_="

--=_alternative 005B384E86256D09_=
Content-Type: text/plain; charset="us-ascii"

Zope 2.6.1 running under IIS on a Windows 2000 Server, with PCGI.
Client browser is IE v5.50.4522.1800 running on Windows 2000 Professional. 
 Also tried with Mozilla 1.0 under Debian.

Gathering this info for you made me think about the PCGI interface, and I 
discovered something interesting.  The redirect works great when I'm going 
direct to Zope port 8080 (not using PCGI).  It manifests the initial 
request problem when using the PCGI interface.  In fact, that's why 
Konqueror worked.  I was going direct to port 8080 when I was trying 
Konqueror.

Brad





Chris McDonough <chrism@zope.com>
04/15/2003 11:12 AM

        To:     Brad Powell/PPCO@Phillips
        cc:     zope@zope.org
        Subject:        Re: [Zope] Help with session data and redirects


I'm afraid I can't reproduce this behavior.  Which
browser(s)/platform(s) does it occur under?

On Tue, 2003-04-15 at 12:06, Brad Powell wrote:
> Thanks, Chris, for the quick reply.  I tried both of your suggestions: 
the 
> random query string and the setHeader statements in the ZPT.  They both 
> improved the situation in that requests after the initial one are now 
> returned properly.  However, the very first request still returns the 
"Problem: no session object (redirectTest)" message.  By the way, instead 
of a response.redirect, if I return the page 
> template directly in the script with a statement like "return 
> container['view_session_obj.pt']()", it works perfectly.  Unfortunately, 
I 
> need the redirect because of the way my actual page template works.
> 
> Brad
> 
> 
> 
> 
> 
> Chris McDonough <chrism@zope.com>
> 04/15/2003 10:18 AM
> 
>         To:     Brad Powell/PPCO@Phillips
>         cc:     zope@zope.org
>         Subject:        Re: [Zope] Help with session data and redirects
> 
> 
> Under Mozilla 1.3 on Linux, when running your test (e.g. when visiting
> /createSessionAndRedirect?sessionText=456), I immediately get:
> 
> ## Page Template "view_session_obj.pt" ##
> 
> 456
> 
> Like you, I suspect this may be a browser issue. 
> 
> To verify, cause the createSessionAndRedirect to generate a "random"
> query string like this:
> 
> session = context.REQUEST.SESSION
> sessionObjName = 'redirectTest'
> session.set(sessionObjName, sessionText)
> return
> 
context.REQUEST.RESPONSE.redirect(context["view_session_obj.pt"].absolute_url() 

> + '?abc=%s' % context.ZopeTime().timeTime())
> 
> This should prevent browsers from returning a cached page.  A more
> permanent solution would be to set a Pragma: No-Cache or Cache-Control:
> No-Cache HTTP header within "view_session_obj.pt".
> 
> - C
> 
> 
> On Tue, 2003-04-15 at 10:58, Brad Powell wrote:
> > I have a problem where session data does not appear to be updated when 

> the 
> > setting of the session data is followed by a response.redirect in a 
> Python 
> > script.  A browser refresh is required to get the correct data 
> displayed. 
> > This happens on both Zope v2.5.1 and v2.6.1.  It also happens with IE 
> and 
> > Mozilla browsers; but, interestingly, it does not occur with the 
> Konqueror 
> > browser.  This led me to believe it was a browser issue, but no matter 

> > what options I try in IE, I cannot get it to work.  I thought it might 

> be 
> > an issue with the browser cache settings, but, again, no matter what I 

> try 
> > I get the same result.
> > 
> > I've included a test script and page template that demonstrates this 
> > problem. When I go to url "sessionCreateAndRedirect?sessionText=123", 
I 
> > get the message, "Problem: no session object (redirectTest)."  If I 
then 
> 
> > refresh the browser, I get "123" displayed, which is the correct 
> response. 
> >  Subsequent calls to the url with different values for sessionText 
> returns 
> > the previous session value, until I do a browser refresh.
> > 
> > Any assistance, guidance, wisdom, etc. on this matter would be greatly 

> > appreciated.
> > 
> > 
> > ## Script (Python) "sessionCreateAndRedirect"
> > ##parameters=sessionText
> > ##
> > session = context.REQUEST.SESSION
> > sessionObjName = 'redirectTest'
> > session.set(sessionObjName, sessionText)
> > return 
> > 
> 
context.REQUEST.RESPONSE.redirect(context["view_session_obj.pt"].absolute_url())
> > 
> > ## Page Template "view_session_obj.pt"
> > ##
> > <html>
> >   <head>
> >     <title tal:content="template/title">The title</title>
> >   </head>
> >   <body>
> >     <tal:block define="global sesObj request/SESSION/redirectTest | 
> > nothing"></tal:block>
> >     <p tal:condition="not:sesObj">Problem: no session object 
> > (redirectTest).</p>
> >     <p tal:condition="sesObj" tal:content="sesObj">session obj 
> > contents</p>
> >   </body>
> > </html>
> > 
> > 
> > Brad
> 
> 
> 
> 





--=_alternative 005B384E86256D09_=
Content-Type: text/html; charset="us-ascii"


<br><font size=2 face="sans-serif">Zope 2.6.1 running under IIS on a Windows 2000 Server, with PCGI.</font>
<br><font size=2 face="sans-serif">Client browser is IE v5.50.4522.1800 running on Windows 2000 Professional. &nbsp;Also tried with Mozilla 1.0 under Debian.</font>
<br>
<br><font size=2 face="sans-serif">Gathering this info for you made me think about the PCGI interface, and I discovered something interesting. &nbsp;The redirect works great when I'm going direct to Zope port 8080 (not using PCGI). &nbsp;It manifests the initial request problem when using the PCGI interface. &nbsp;In fact, that's why Konqueror worked. &nbsp;I was going direct to port 8080 when I was trying Konqueror.</font>
<br>
<br><font size=2 face="sans-serif">Brad</font>
<br>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td>
<td><font size=1 face="sans-serif"><b>Chris McDonough &lt;chrism@zope.com&gt;</b></font>
<p><font size=1 face="sans-serif">04/15/2003 11:12 AM</font>
<br>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; To: &nbsp; &nbsp; &nbsp; &nbsp;Brad Powell/PPCO@Phillips</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; cc: &nbsp; &nbsp; &nbsp; &nbsp;zope@zope.org</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; Subject: &nbsp; &nbsp; &nbsp; &nbsp;Re: [Zope] Help with session data and redirects</font></table>
<br>
<br>
<br><font size=2 face="Courier New">I'm afraid I can't reproduce this behavior. &nbsp;Which<br>
browser(s)/platform(s) does it occur under?<br>
<br>
On Tue, 2003-04-15 at 12:06, Brad Powell wrote:<br>
&gt; Thanks, Chris, for the quick reply. &nbsp;I tried both of your suggestions: the <br>
&gt; random query string and the setHeader statements in the ZPT. &nbsp;They both <br>
&gt; improved the situation in that requests after the initial one are now <br>
&gt; returned properly. &nbsp;However, the very first request still returns the &quot;Problem: no session object (redirectTest)&quot; message. &nbsp;By the way, instead of a response.redirect, if I return the page <br>
&gt; template directly in the script with a statement like &quot;return <br>
&gt; container['view_session_obj.pt']()&quot;, it works perfectly. &nbsp;Unfortunately, I <br>
&gt; need the redirect because of the way my actual page template works.<br>
&gt; <br>
&gt; Brad<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; Chris McDonough &lt;chrism@zope.com&gt;<br>
&gt; 04/15/2003 10:18 AM<br>
&gt; <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; To: &nbsp; &nbsp; Brad Powell/PPCO@Phillips<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; cc: &nbsp; &nbsp; zope@zope.org<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; Subject: &nbsp; &nbsp; &nbsp; &nbsp;Re: [Zope] Help with session data and redirects<br>
&gt; <br>
&gt; <br>
&gt; Under Mozilla 1.3 on Linux, when running your test (e.g. when visiting<br>
&gt; /createSessionAndRedirect?sessionText=456), I immediately get:<br>
&gt; <br>
&gt; ## Page Template &quot;view_session_obj.pt&quot; ##<br>
&gt; <br>
&gt; 456<br>
&gt; <br>
&gt; Like you, I suspect this may be a browser issue. <br>
&gt; <br>
&gt; To verify, cause the createSessionAndRedirect to generate a &quot;random&quot;<br>
&gt; query string like this:<br>
&gt; <br>
&gt; session = context.REQUEST.SESSION<br>
&gt; sessionObjName = 'redirectTest'<br>
&gt; session.set(sessionObjName, sessionText)<br>
&gt; return<br>
&gt; context.REQUEST.RESPONSE.redirect(context[&quot;view_session_obj.pt&quot;].absolute_url() <br>
&gt; + '?abc=%s' % context.ZopeTime().timeTime())<br>
&gt; <br>
&gt; This should prevent browsers from returning a cached page. &nbsp;A more<br>
&gt; permanent solution would be to set a Pragma: No-Cache or Cache-Control:<br>
&gt; No-Cache HTTP header within &quot;view_session_obj.pt&quot;.<br>
&gt; <br>
&gt; - C<br>
&gt; <br>
&gt; <br>
&gt; On Tue, 2003-04-15 at 10:58, Brad Powell wrote:<br>
&gt; &gt; I have a problem where session data does not appear to be updated when <br>
&gt; the <br>
&gt; &gt; setting of the session data is followed by a response.redirect in a <br>
&gt; Python <br>
&gt; &gt; script. &nbsp;A browser refresh is required to get the correct data <br>
&gt; displayed. <br>
&gt; &gt; This happens on both Zope v2.5.1 and v2.6.1. &nbsp;It also happens with IE <br>
&gt; and <br>
&gt; &gt; Mozilla browsers; but, interestingly, it does not occur with the <br>
&gt; Konqueror <br>
&gt; &gt; browser. &nbsp;This led me to believe it was a browser issue, but no matter <br>
&gt; &gt; what options I try in IE, I cannot get it to work. &nbsp;I thought it might <br>
&gt; be <br>
&gt; &gt; an issue with the browser cache settings, but, again, no matter what I <br>
&gt; try <br>
&gt; &gt; I get the same result.<br>
&gt; &gt; <br>
&gt; &gt; I've included a test script and page template that demonstrates this <br>
&gt; &gt; problem. When I go to url &quot;sessionCreateAndRedirect?sessionText=123&quot;, I <br>
&gt; &gt; get the message, &quot;Problem: no session object (redirectTest).&quot; &nbsp;If I then <br>
&gt; <br>
&gt; &gt; refresh the browser, I get &quot;123&quot; displayed, which is the correct <br>
&gt; response. <br>
&gt; &gt; &nbsp;Subsequent calls to the url with different values for sessionText <br>
&gt; returns <br>
&gt; &gt; the previous session value, until I do a browser refresh.<br>
&gt; &gt; <br>
&gt; &gt; Any assistance, guidance, wisdom, etc. on this matter would be greatly <br>
&gt; &gt; appreciated.<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; ## Script (Python) &quot;sessionCreateAndRedirect&quot;<br>
&gt; &gt; ##parameters=sessionText<br>
&gt; &gt; ##<br>
&gt; &gt; session = context.REQUEST.SESSION<br>
&gt; &gt; sessionObjName = 'redirectTest'<br>
&gt; &gt; session.set(sessionObjName, sessionText)<br>
&gt; &gt; return <br>
&gt; &gt; <br>
&gt; context.REQUEST.RESPONSE.redirect(context[&quot;view_session_obj.pt&quot;].absolute_url())<br>
&gt; &gt; <br>
&gt; &gt; ## Page Template &quot;view_session_obj.pt&quot;<br>
&gt; &gt; ##<br>
&gt; &gt; &lt;html&gt;<br>
&gt; &gt; &nbsp; &lt;head&gt;<br>
&gt; &gt; &nbsp; &nbsp; &lt;title tal:content=&quot;template/title&quot;&gt;The title&lt;/title&gt;<br>
&gt; &gt; &nbsp; &lt;/head&gt;<br>
&gt; &gt; &nbsp; &lt;body&gt;<br>
&gt; &gt; &nbsp; &nbsp; &lt;tal:block define=&quot;global sesObj request/SESSION/redirectTest | <br>
&gt; &gt; nothing&quot;&gt;&lt;/tal:block&gt;<br>
&gt; &gt; &nbsp; &nbsp; &lt;p tal:condition=&quot;not:sesObj&quot;&gt;Problem: no session object <br>
&gt; &gt; (redirectTest).&lt;/p&gt;<br>
&gt; &gt; &nbsp; &nbsp; &lt;p tal:condition=&quot;sesObj&quot; tal:content=&quot;sesObj&quot;&gt;session obj <br>
&gt; &gt; contents&lt;/p&gt;<br>
&gt; &gt; &nbsp; &lt;/body&gt;<br>
&gt; &gt; &lt;/html&gt;<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; Brad<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
<br>
<br>
</font>
<br>
<br>
--=_alternative 005B384E86256D09_=--

------=_NextPartTM-000-ea45a06c-f9fc-40c6-a725-4dd18633cc77--