<HTML><BODY>
<DIV>Hi:</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;Thanks to Michael Dunstan. I test with the recomendation of 
Michael but I still get the error. In pages where I get the error, if I wait 
<SPAN>some </SPAN>seconds and refresh the pages, I obtain the correct 
information (no get the error).</DIV>
<DIV>&nbsp;</DIV>
<DIV>I thinks that the problem maybe are similar to the guess of Michael, 
but I test "breaking up ``init2`` into two scripts" and the error don't 
<SPAN>disappear</SPAN>. :(</DIV>
<DIV>&nbsp;</DIV>
<DIV>Any help will be useful.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks in advance, </DIV>
<DIV>&nbsp;</DIV>
<DIV>Leticia Larrosa</DIV>
<DIV><BR>-----Original Message-----<BR>From: Michael Dunstan 
&lt;michael@looma.co.nz&gt;<BR>To: Leticia Larrosa 
&lt;LETICIA@tesla.cujae.edu.cu&gt;<BR>Cc: zope@zope.org<BR>Date: Tue, 21 Jun 
2005 10:19:53 +1200<BR>Subject: Re: [Zope] accessing session data error<BR>
<BR>&gt; Hi Leticia,<BR>&gt; <BR>&gt; The mixture of ``response.write()`` 
including JavaScript to drive the &nbsp;<BR>&gt; browser to a new location 
along with writing objects in ZODB all &nbsp;<BR>&gt; within the same 
transaction can break some of the promises that you'd &nbsp;<BR>&gt; 
normally expect Zope and a browser to keep.<BR>&gt; <BR>&gt; My guess is 
that browser is being told to visit ``end`` before the &nbsp;<BR>&gt; 
transaction started by ``init2`` has finished. Perhaps a conflict &nbsp;<BR>
&gt; error is causing that transaction to take longer than you expect. 
&nbsp;<BR>&gt; Normally this would not trip you up as your browser does not 
see &nbsp;<BR>&gt; anything until after the transaction has finished. (In 
this normal &nbsp;<BR>&gt; mode you might see a conflict error rendered in 
the browser if the &nbsp;<BR>&gt; publication machinery had to give up.)<BR>
&gt; <BR>&gt; For your example try breaking up ``init2`` into two scripts. 
The &nbsp;<BR>&gt; first that writes the session data and then redirects the 
browser to &nbsp;<BR>&gt; the second. The second then does not touch session 
data and manages &nbsp;<BR>&gt; all the ``response.write()``s. And remove 
the unused ``sessionData = &nbsp;<BR>&gt; context.REQUEST.SESSION`` from 
``external``.<BR>&gt; <BR>&gt; Cheers<BR>&gt; Michael<BR>&gt; <BR>&gt; On 
21/06/2005, at 6:20 AM, Leticia Larrosa wrote:<BR>&gt; <BR>&gt; &gt; Hi 
all:<BR>&gt; &gt;<BR>&gt; &gt; I think that I found a ZOPE bug. Is really 
very important for me &nbsp;<BR>&gt; &gt; know what can I do for avoid it. 
The first 9 steps are to recreate &nbsp;<BR>&gt; &gt; the situation and the 
other steps are to provoke the error.<BR>&gt; &gt;<BR>&gt; &gt; Step 1: 
Crate a folder called "reproducingError" in Zope Interface &nbsp;<BR>&gt; 
&gt; Manage<BR>&gt; &gt;<BR>&gt; &gt; Step 2: create a page template called 
"index_html" in the &nbsp;<BR>&gt; &gt; "reproducingError" folder with the 
following content:<BR>&gt; &gt; "<BR>&gt; &gt; &lt;!-- index_html page 
template --&gt;<BR>&gt; &gt; &lt;form name="form1" method="post" 
action="reproducingError/init"&gt;<BR>&gt; &gt; &nbsp; &lt;input type="text" 
name="user"&gt;<BR>&gt; &gt; &nbsp; &lt;input type="submit" name="Submit" 
value="Submit"&gt;<BR>&gt; &gt; &lt;/form&gt;<BR>&gt; &gt; "<BR>&gt; &gt;<BR>
&gt; &gt; Step 3: create a python script called "init" in the &nbsp;<BR>&gt; 
&gt; "reproducingError" folder with the following content:<BR>&gt; &gt; "<BR>
&gt; &gt; # init script<BR>&gt; &gt; sessionData = 
container.REQUEST.SESSION<BR>&gt; &gt; sessionData.set("userId", 
container.REQUEST.user)<BR>&gt; &gt; return context.init2_html()<BR>&gt; 
&gt; "<BR>&gt; &gt;<BR>&gt; &gt; Step 4: create a page template called 
"init2_html" in the &nbsp;<BR>&gt; &gt; "reproducingError" folder with the 
following content:<BR>&gt; &gt; "<BR>&gt; &gt; &lt;!-- init2_html page 
template --&gt;<BR>&gt; &gt; &lt;a href="init2"&gt;passing face 
2&lt;/a&gt;<BR>&gt; &gt; "<BR>&gt; &gt;<BR>&gt; &gt; Step 5: create a python 
script called "init2" in the &nbsp;<BR>&gt; &gt; "reproducingError" folder 
with the following content:<BR>&gt; &gt; "<BR>&gt; &gt; # init2 script<BR>
&gt; &gt; request = context.REQUEST<BR>&gt; &gt; sessionData = 
request.SESSION<BR>&gt; &gt; sessionData.set('idService', 'testService')<BR>
&gt; &gt; context.first()<BR>&gt; &gt; return context.external(context)<BR>
&gt; &gt; "<BR>&gt; &gt;<BR>&gt; &gt; Step 6: create a page template called 
"first_html" in the &nbsp;<BR>&gt; &gt; "reproducingError" folder with the 
following content:<BR>&gt; &gt; "<BR>&gt; &gt; First Response<BR>&gt; &gt; 
"<BR>&gt; &gt;<BR>&gt; &gt; Step 7: create a python script called "first" in 
the &nbsp;<BR>&gt; &gt; "reproducingError" folder with the following 
content:<BR>&gt; &gt; "<BR>&gt; &gt; # first script<BR>&gt; &gt; response = 
container.REQUEST.RESPONSE<BR>&gt; &gt; str = container.first_html()<BR>&gt; 
&gt; response.write(str)<BR>&gt; &gt; response.flush()<BR>&gt; &gt; "<BR>
&gt; &gt;<BR>&gt; &gt; Step 8: create an external method called "external" 
in the &nbsp;<BR>&gt; &gt; "reproducingError" folder with the following 
content, in where the &nbsp;<BR>&gt; &gt; function of the external method is 
"communicationResponse" and the &nbsp;<BR>&gt; &gt; module is any name that 
you give to the file:<BR>&gt; &gt; "<BR>&gt; &gt; # external method<BR>&gt; 
&gt; import time<BR>&gt; &gt; def communicationResponse(context):<BR>&gt; 
&gt; &nbsp; &nbsp; response = context.REQUEST.RESPONSE<BR>&gt; &gt; &nbsp; 
&nbsp; sessionData = context.REQUEST.SESSION<BR>&gt; &gt; &nbsp; &nbsp; 
strDetailEnd = "&lt;script&gt;window.location='reproducingError/end'&lt;/ 
<BR>&gt; &gt; script&gt;"<BR>&gt; &gt;<BR>&gt; &gt; &nbsp; &nbsp; for item 
in range(1, 40):<BR>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; time.sleep(3)<BR>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; response.write("Response iteration:" + 
str(item))<BR>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; response.flush()<BR>&gt; 
&gt; &nbsp; &nbsp; response.write(strDetailEnd)<BR>&gt; &gt; &nbsp; &nbsp; 
response.flush()<BR>&gt; &gt; "<BR>&gt; &gt;<BR>&gt; &gt; Step 9: create a 
python script called "end" in the &nbsp;<BR>&gt; &gt; "reproducingError" 
folder with the following content:<BR>&gt; &gt; "<BR>&gt; &gt; # end 
script<BR>&gt; &gt; idService = context.REQUEST.SESSION['idService']<BR>&gt; 
&gt; return "Fin - " + idService<BR>&gt; &gt; "<BR>&gt; &gt;<BR>&gt; &gt; 
Step 10: open two explorer in wich call the object &nbsp;<BR>&gt; &gt; 
"reproducingError" (Example: localhost:8080/reproducingError)<BR>&gt; 
&gt;<BR>&gt; &gt; Step 11: enter an example text in each one.<BR>&gt; 
&gt;<BR>&gt; &gt; Step 12: clink in the link of one of them, and 5 second 
later clink &nbsp;<BR>&gt; &gt; on the link of the other explorer. The 
waiting for around 5 second &nbsp;<BR>&gt; &gt; is necesary because with 
other time interval not allways get the &nbsp;<BR>&gt; &gt; error.<BR>&gt; 
&gt;<BR>&gt; &gt; Stpe 13: and wait the "Response iteration"... &nbsp;Please 
if the error &nbsp;<BR>&gt; &gt; don't appear in any of the pages, begins at 
Step 9 again. and try &nbsp;<BR>&gt; &gt; to count to 5 witch other velocity 
:)<BR>&gt; &gt;<BR>&gt; &gt; The correct result is:<BR>&gt; &gt; "<BR>&gt; 
&gt; Fin - testService<BR>&gt; &gt; "<BR>&gt; &gt;<BR>&gt; &gt; The error 
is:<BR>&gt; &gt; "<BR>&gt; &gt; Site Error<BR>&gt; &gt; An error was 
encountered while publishing this resource.<BR>&gt; &gt; Error Type: 
KeyError<BR>&gt; &gt; Error Value: 'idService'<BR>&gt; &gt; "<BR>&gt; &gt; 
The traceback:<BR>&gt; &gt; "<BR>&gt; &gt; Traceback (innermost last):<BR>
&gt; &gt; &nbsp; Module ZPublisher.Publish, line 101, in publish<BR>&gt; 
&gt; &nbsp; Module ZPublisher.mapply, line 88, in mapply<BR>&gt; &gt; &nbsp; 
Module ZPublisher.Publish, line 39, in call_object<BR>&gt; &gt; &nbsp; 
Module Shared.DC.Scripts.Bindings, line 306, in __call__<BR>&gt; &gt; &nbsp; 
Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec<BR>&gt; &gt; 
&nbsp; Module Products.PythonScripts.PythonScript, line 323, in _exec<BR>
&gt; &gt; &nbsp; Module None, line 2, in end<BR>&gt; &gt; &nbsp; &nbsp;- 
&lt;PythonScript at /approach/reproducingError/end&gt;<BR>&gt; &gt; &nbsp; 
&nbsp;- Line 2<BR>&gt; &gt; &nbsp; Module AccessControl.ZopeGuards, line 67, 
in guarded_getitem<BR>&gt; &gt; &nbsp; Module 
Products.Transience.TransientObject, line 176, in<BR>&gt; __getitem__<BR>
&gt; &gt; KeyError: 'idService'<BR>&gt; &gt; "<BR>&gt; &gt;<BR>&gt; &gt; I 
will appreciate if you try until the error appear, because I not &nbsp;<BR>
&gt; &gt; always obtain the error. I thinks that it is bacause the time 
&nbsp;<BR>&gt; &gt; interval between the two request.<BR>&gt; &gt;<BR>&gt; 
&gt; A curious thing is that when I obtain the error, if I wait around 
&nbsp;<BR>&gt; &gt; 15 second and refresh the page in wich i obtain the 
error, the &nbsp;<BR>&gt; &gt; correct result appear.. and no errors 
come.<BR>&gt; &gt;<BR>&gt; &gt; Sorry for the extended message, but I need 
any help that you can &nbsp;<BR>&gt; &gt; give me, because this describe 
error environment imitate a &nbsp;<BR>&gt; &gt; funcionality that I must 
give in a system very import that i'm doing.<BR>&gt; &gt;<BR>&gt; &gt; I'm 
using Zope 2.7.6 for Windows.<BR>&gt; &gt;<BR>&gt; &gt; Thanks in 
advanced.<BR>&gt; &gt; Leticia<BR>&gt; &gt; 
_______________________________________________<BR>&gt; &gt; Zope maillist 
&nbsp;- &nbsp;Zope@zope.org<BR>&gt; &gt; 
http://mail.zope.org/mailman/listinfo/zope<BR>&gt; &gt; ** &nbsp; No cross 
posts or HTML encoding! &nbsp;**<BR>&gt; &gt; (Related lists -<BR>&gt; &gt; 
&nbsp;http://mail.zope.org/mailman/listinfo/zope-announce<BR>&gt; &gt; 
&nbsp;http://mail.zope.org/mailman/listinfo/zope-dev )<BR>&gt; &gt;<BR>&gt; 
<BR>&gt; _______________________________________________<BR>&gt; Zope 
maillist &nbsp;- &nbsp;Zope@zope.org<BR>&gt; 
http://mail.zope.org/mailman/listinfo/zope<BR>&gt; ** &nbsp; No cross posts 
or HTML encoding! &nbsp;**<BR>&gt; (Related lists - <BR>&gt; 
&nbsp;http://mail.zope.org/mailman/listinfo/zope-announce<BR>&gt; 
&nbsp;http://mail.zope.org/mailman/listinfo/zope-dev )<BR>&gt; <BR>&gt; <BR>
</DIV>
</BODY></HTML>