[Zope] accessing session data error

Leticia Larrosa LETICIA at tesla.cujae.edu.cu
Tue Jun 21 12:50:53 EDT 2005


Hi:

 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 some seconds 
and refresh the pages, I obtain the correct information (no get the error).

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 disappear. 
:(

Any help will be useful.

Thanks in advance, 

Leticia Larrosa

-----Original Message-----
From: Michael Dunstan <michael at looma.co.nz>
To: Leticia Larrosa <LETICIA at tesla.cujae.edu.cu>
Cc: zope at zope.org
Date: Tue, 21 Jun 2005 10:19:53 +1200
Subject: Re: [Zope] accessing session data error

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


More information about the Zope mailing list