Re: [Zope] accessing session data error

2005-06-22 Thread Leticia Larrosa
Hi all: 
 
Thanks to Paul Winkler for his FWIW. 
Thanks a lot to Michael Dunstan for insists in the fact of 
response.redirect('init2-second-half'), because like he perhaps imagined I 
do the return init2-second-half instead of redirect.
 
 I test with the redirect and the error disapear, for now ; )

Thanks to all the community for establish a support for everyone.
 Leticia

-Original Message-
From: Michael Dunstan [EMAIL PROTECTED]
To: Leticia Larrosa [EMAIL PROTECTED]
Cc: zope@zope.org
Date: Wed, 22 Jun 2005 08:55:31 +1200
Subject: Re: [Zope] accessing session data error

 On 22/06/2005, at 4:50 AM, Leticia Larrosa wrote:
 
  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
 
 Hi Leticia,
 
 Just double check that you are redirecting from the init2-first-half  
 to init2-second-half. Using something like the following in init2- 
 first-half::
 
response.redirect('init2-second-half')
 
 rather than directly calling init2-second-half.
 
 Cheers
 Michael
 ___
 Zope maillist  -  Zope@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@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 )


Re: [Zope] accessing session data error

2005-06-21 Thread Leticia Larrosa

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 
[EMAIL PROTECTED]To: Leticia Larrosa 
[EMAIL PROTECTED]Cc: zope@zope.orgDate: Tue, 21 Jun 
2005 10:19:53 +1200Subject: 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=""   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=""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 = "scriptwindow.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

Re: [Zope] accessing session data error

2005-06-21 Thread Michael Dunstan

On 22/06/2005, at 4:50 AM, Leticia Larrosa wrote:


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


Hi Leticia,

Just double check that you are redirecting from the init2-first-half  
to init2-second-half. Using something like the following in init2- 
first-half::


  response.redirect('init2-second-half')

rather than directly calling init2-second-half.

Cheers
Michael
___
Zope maillist  -  Zope@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 )


Re: [Zope] accessing session data error

2005-06-21 Thread Paul Winkler
On Mon, Jun 20, 2005 at 05:20:29PM -0400, Leticia Larrosa wrote:
 Hi:
 
  I follow the steps to replicate the error in zope2.7 for Debian and i get 
 the error to.

fwiw, I have not been able to reproduce this following your instructions
(zope 2.7.6 running on gentoo linux; browser is IE 6.whatever
on win2k).
 
-- 

Paul Winkler
http://www.slinkp.com
___
Zope maillist  -  Zope@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] accessing session data error

2005-06-20 Thread Leticia Larrosa


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="" 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 scriptsessionData = 
container.REQUEST.SESSIONsessionData.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=""passing face 2/a"



Step 5: create a python script called "init2" in the "reproducingError" 
folder with the following content:"# init2 scriptrequest = 
context.REQUESTsessionData = 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 scriptresponse = 
container.REQUEST.RESPONSEstr = 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 methodimport time

def communicationResponse(context):

 response = context.REQUEST.RESPONSE 
sessionData = context.REQUEST.SESSION strDetailEnd = 
"scriptwindow.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 scriptidService = 
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 ErrorAn error was encountered while publishing this resource. 


Error Type: KeyErrorError 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@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 )


Re: [Zope] accessing session data error

2005-06-20 Thread Chris McDonough
Hi Leticia,

Thanks for the detailed bug report.

I have tried to replicate the bug as you indicate below but cannot.
I've gone through the process you describe ten times without errors (in
Zope 2.7.6).

If it's possible to simplify the steps to recreate the error, that would
be helpful in further debugging (for example, maybe just getting rid of
all the page templates and python scripts and just using a single
external method).

- C


On Mon, 2005-06-20 at 14:20 -0400, 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=init2passing 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 =
 scriptwindow.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.
  
 

Re: [Zope] accessing session data error

2005-06-20 Thread Leticia Larrosa

Hi:

Thanks for the rapid aswer of Chris McDonough. I will change the 
steps to replicate the error (sorry for the large steps before :( , I thinks 
that maybe was needful). Remember that the key of the error is the time 
interval between the request. If with 5 seconds don't appear the 
errortry to vary to other, like 7 seconds. The 5 first steps are to 
create the situation and thesixth step are to provoke the 
error

Step 1: Create a folder called "reproducingError" in Zope Interface
Manage

Step 2: Create a srcipt "end" with the content:
"
# end scriptidService = context.REQUEST.SESSION['idService']
return "Fin - " + idService"

Step 3: Create a script "index_html" with the content:
"
# init scriptsessionData = container.REQUEST.SESSION
sessionData.set("userId", "userExample")return context.init2()
"

Step 4: Create a script "init2" with the content:
"
# init2 scriptrequest = context.REQUESTsessionData = 
request.SESSIONsessionData.set('idService', 'testService')return 
context.external(context)
"

Step 5: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 methodimport time
def communicationResponse(context):
 response = context.REQUEST.RESPONSE
 sessionData = context.REQUEST.SESSION
 strDetailEnd = 
"scriptwindow.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 6: opentwo explorer
In one of them call the object "reproducingError" (Example: 
localhost:8080/reproducingError), then wait 5 second and put in the other 
the same direction.
And wait the iterations

Note: I count 5 second, not with chronometer. You can try 
with a near number.

Chris: I reproduce the error with the steps. I can't reduce it to an 
external method. Thanks again.

The error that I obtain is the same:
"
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'
"
Remember:
  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.

  I'm using Zope 2.7.6 for Windows.

I must solve this, because this is part of my thesis for university 
graduation. Any help will be appreciated.

Thanks in advance, 
Leticia Larrosa
-Original Message-From: Chris McDonough 
[EMAIL PROTECTED]To: Leticia Larrosa 
[EMAIL PROTECTED]Cc: zope@zope.orgDate: Mon, 20 Jun 
2005 15:12:21 -0400Subject: Re: [Zope] accessing session data error
 Hi Leticia,  Thanks for the detailed bug report.
  I have tried to replicate the bug as you indicate below but 
cannot. I've gone through the process you describe ten times without 
errors (in Zope 2.7.6).  If it's possible to 
simplify the steps to recreate the error, that would be 
helpful in further debugging (for example, maybe just getting rid of 
all the page templates and python scripts and just using a single 
external method).  - C   On Mon, 
2005-06-20 at 14:20 -0400, 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=""   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_

Re: [Zope] accessing session data error

2005-06-20 Thread Leticia Larrosa

Hi:

I follow the steps to replicate the errorin zope2.7 for 
Debian and i get the error to.

Thanks in advanced, Leticia

-Original 
Message-From: "Leticia Larrosa" 
[EMAIL PROTECTED]To: "Chris McDonough" 
[EMAIL PROTECTED]Cc: zope@zope.orgDate: Mon, 20 Jun 2005 
16:25:08 -0400Subject: Re: [Zope] accessing session data error
Hi:

Thanks for the rapid aswer of Chris McDonough. I will change the 
steps to replicate the error (sorry for the large steps before :( , I thinks 
that maybe was needful). Remember that the key of the error is the time 
interval between the request. If with 5 seconds don't appear the 
errortry to vary to other, like 7 seconds. The 5 first steps are to 
create the situation and thesixth step are to provoke the 
error

Step 1: Create a folder called "reproducingError" in Zope Interface
Manage

Step 2: Create a srcipt "end" with the content:
"
# end scriptidService = context.REQUEST.SESSION['idService']
return "Fin - " + idService"

Step 3: Create a script "index_html" with the content:
"
# init scriptsessionData = container.REQUEST.SESSION
sessionData.set("userId", "userExample")return context.init2()
"

Step 4: Create a script "init2" with the content:
"
# init2 scriptrequest = context.REQUESTsessionData = 
request.SESSIONsessionData.set('idService', 'testService')return 
context.external(context)
"

Step 5: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 methodimport time
def communicationResponse(context):
 response = context.REQUEST.RESPONSE
 sessionData = context.REQUEST.SESSION
 strDetailEnd = 
"scriptwindow.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 6: opentwo explorer
In one of them call the object "reproducingError" (Example: 
localhost:8080/reproducingError), then wait 5 second and put in the other 
the same direction.
And wait the iterations

Note: I count 5 second, not with chronometer. You can try 
with a near number.

Chris: I reproduce the error with the steps. I can't reduce it to an 
external method. Thanks again.

The error that I obtain is the same:
"
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'
"
Remember:
  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.

  I'm using Zope 2.7.6 for Windows.

I must solve this, because this is part of my thesis for university 
graduation. Any help will be appreciated.

Thanks in advance, 
Leticia Larrosa
-----Original Message-From: Chris McDonough 
[EMAIL PROTECTED]To: Leticia Larrosa 
[EMAIL PROTECTED]Cc: zope@zope.orgDate: Mon, 20 Jun 
2005 15:12:21 -0400Subject: Re: [Zope] accessing session data error
 Hi Leticia,  Thanks for the detailed bug report.
  I have tried to replicate the bug as you indicate below but 
cannot. I've gone through the process you describe ten times without 
errors (in Zope 2.7.6).  If it's possible to 
simplify the steps to recreate the error, that would be 
helpful in further debugging (for example, maybe just getting rid of 
all the page templates and python scripts and just using a single 
external method).  - C   On Mon, 
2005-06-20 at 14:20 -0400, 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=""   input type="text" 
name="user"   input type="submit" name="Submit" 
value="Submit"  /form

Re: [Zope] accessing session data error

2005-06-20 Thread Michael Dunstan

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=init2passing 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 = scriptwindow.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