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