[Zope] Help with session data and redirects

Brad Powell Brad.Powell@conocophillips.com
Tue, 15 Apr 2003 09:58:11 -0500


This is a multipart message in MIME format.
------=_NextPartTM-000-21dbea50-79e0-46ed-88b0-fa80d2c3cbee
Content-Type: multipart/alternative; 
	boundary="=_alternative 00523AF186256D09_="

--=_alternative 00523AF186256D09_=
Content-Type: text/plain; charset="us-ascii"

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 00523AF186256D09_=
Content-Type: text/html; charset="us-ascii"


<br><font size=2 face="sans-serif">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. &nbsp;A browser refresh is required to get the correct data displayed. &nbsp;This happens on both Zope v2.5.1 and v2.6.1. &nbsp;It also happens with IE and Mozilla browsers; but, interestingly, it does not occur with the Konqueror browser. &nbsp;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. &nbsp;I thought it might be an issue with the browser cache settings, but, again, no matter what I try I get the same result.</font>
<br>
<br><font size=2 face="sans-serif">I've included a test script and page template that demonstrates this problem. When I go to url &quot;sessionCreateAndRedirect?sessionText=123&quot;, I get the message, &quot;Problem: no session object (redirectTest).&quot; &nbsp;If I then refresh the browser, I get &quot;123&quot; displayed, which is the correct response. &nbsp;Subsequent calls to the url with different values for sessionText returns the previous session value, until I do a browser refresh.</font>
<br>
<br><font size=2 face="sans-serif">Any assistance, guidance, wisdom, etc. on this matter would be greatly appreciated.</font>
<br>
<br>
<br><font size=2 face="sans-serif">## Script (Python) &quot;sessionCreateAndRedirect&quot;</font>
<br><font size=2 face="sans-serif">##parameters=sessionText</font>
<br><font size=2 face="sans-serif">##</font>
<br><font size=2 face="sans-serif">session = context.REQUEST.SESSION</font>
<br><font size=2 face="sans-serif">sessionObjName = 'redirectTest'</font>
<br><font size=2 face="sans-serif">session.set(sessionObjName, sessionText)</font>
<br><font size=2 face="sans-serif">return context.REQUEST.RESPONSE.redirect(context[&quot;view_session_obj.pt&quot;].absolute_url())</font>
<br>
<br><font size=2 face="sans-serif">## Page Template &quot;view_session_obj.pt&quot;</font>
<br><font size=2 face="sans-serif">##</font>
<br><font size=2 face="sans-serif">&lt;html&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &lt;head&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &lt;title tal:content=&quot;template/title&quot;&gt;The title&lt;/title&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &lt;/head&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &lt;body&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &lt;tal:block define=&quot;global sesObj request/SESSION/redirectTest | nothing&quot;&gt;&lt;/tal:block&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &lt;p tal:condition=&quot;not:sesObj&quot;&gt;Problem: no session object (redirectTest).&lt;/p&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &lt;p tal:condition=&quot;sesObj&quot; tal:content=&quot;sesObj&quot;&gt;session obj contents&lt;/p&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &lt;/body&gt;</font>
<br><font size=2 face="sans-serif">&lt;/html&gt;</font>
<br>
<br>
<br><font size=2 face="sans-serif">Brad</font>
--=_alternative 00523AF186256D09_=--

------=_NextPartTM-000-21dbea50-79e0-46ed-88b0-fa80d2c3cbee--