session and iterating session_data
hi in an attempt to provide users with list of those online, i'm using session to keep track of who's logged in , and who's timed out (inactivity) in essence, -when users log in, i start a session, and store their username in the session object -i then have an external method that goes thru session data in temp_folder (where session objects are stored) and iterate thru the session objects, and return the usernames[1] this scheme works, but some, maybe many, times, i encountered Key Error[2, and many times it's the same key error]. is there anything wrong with my way of approcahing this? or is there a better way? zope2.5.1/zope2.6.0b1, python2.1.3, linux help appreciated. tia -- [1] def getsession_data(self): import time l = [] for session in self.temp_folder.session_data.values(): username = session.get('username','Unknown') last_xs = time.ctime(session.getLastAccessed()) l.append((username,last_xs)) return l [2] Error type: KeyError Traceback: <p>Traceback (innermost last): <ul> <li> Module ZPublisher.Publish, line 98, in publish</li> <li> Module ZPublisher.mapply, line 88, in mapply</li> <li> Module ZPublisher.Publish, line 39, in call_object</li> <li> Module OFS.DTMLMethod, line 126, in __call__</li> <li> Module DocumentTemplate.DT_String, line 474, in __call__</li> <li> Module DocumentTemplate.DT_Util, line 201, in eval<br /> __traceback_info__: sc_gSessionData</li> <li> Module <string>, line 2, in f</li> <li> Module Shared.DC.Scripts.Bindings, line 252, in __call__</li> <li> Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec</li> <li> Module Products.PythonScripts.PythonScript, line 315, in _exec</li> <li> Module Script (Python), line 1, in sc_gSessionData<br /> <b><PythonScript at /kk/sc_gSessionData></b><br /> <b>Line 1</b></li> <li> Module Products.ExternalMethod.ExternalMethod, line 231, in __call__<br /> __traceback_info__: ((), {}, None)</li> <li> Module /home/xxx/ZopeHome/Extensions/session.py, line 30, in getsession_data</li> <li> Module Products.Transience.Transience, line 832, in values</li> <li> Module Products.Transience.Transience, line 832, in <lambda></li> <li> Module Products.Transience.Transience, line 755, in __getitem__</li> </ul>KeyError: 1033629200 </p> -- http://www.kedai.com.my/ http://www.kedai.com.my/eZine http://www.zope.org/Members/kedai http://www.my-zope.org I will follow you! Damage Inc.
This is likely to happen under 2.5.1 but not 2.6b1. Are you sure you get the key error under 2.6b1? On Fri, 2002-10-04 at 02:44, Bakhtiar A Hamid wrote:
hi in an attempt to provide users with list of those online, i'm using session to keep track of who's logged in , and who's timed out (inactivity)
in essence, -when users log in, i start a session, and store their username in the session object
-i then have an external method that goes thru session data in temp_folder (where session objects are stored) and iterate thru the session objects, and return the usernames[1]
this scheme works, but some, maybe many, times, i encountered Key Error[2, and many times it's the same key error].
is there anything wrong with my way of approcahing this? or is there a better way?
zope2.5.1/zope2.6.0b1, python2.1.3, linux
help appreciated.
tia -- [1] def getsession_data(self):
import time l = [] for session in self.temp_folder.session_data.values(): username = session.get('username','Unknown') last_xs = time.ctime(session.getLastAccessed()) l.append((username,last_xs)) return l
[2]
Error type: KeyError Traceback: <p>Traceback (innermost last): <ul> <li> Module ZPublisher.Publish, line 98, in publish</li> <li> Module ZPublisher.mapply, line 88, in mapply</li> <li> Module ZPublisher.Publish, line 39, in call_object</li> <li> Module OFS.DTMLMethod, line 126, in __call__</li> <li> Module DocumentTemplate.DT_String, line 474, in __call__</li> <li> Module DocumentTemplate.DT_Util, line 201, in eval<br /> __traceback_info__: sc_gSessionData</li> <li> Module <string>, line 2, in f</li> <li> Module Shared.DC.Scripts.Bindings, line 252, in __call__</li> <li> Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec</li> <li> Module Products.PythonScripts.PythonScript, line 315, in _exec</li> <li> Module Script (Python), line 1, in sc_gSessionData<br /> <b><PythonScript at /kk/sc_gSessionData></b><br /> <b>Line 1</b></li> <li> Module Products.ExternalMethod.ExternalMethod, line 231, in __call__<br /> __traceback_info__: ((), {}, None)</li> <li> Module /home/xxx/ZopeHome/Extensions/session.py, line 30, in getsession_data</li> <li> Module Products.Transience.Transience, line 832, in values</li> <li> Module Products.Transience.Transience, line 832, in <lambda></li> <li> Module Products.Transience.Transience, line 755, in __getitem__</li> </ul>KeyError: 1033629200 </p>
--
http://www.kedai.com.my/ http://www.kedai.com.my/eZine http://www.zope.org/Members/kedai http://www.my-zope.org I will follow you! Damage Inc.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On 4 Oct 2002, Chris McDonough wrote:
This is likely to happen under 2.5.1 but not 2.6b1. Are you sure you get the key error under 2.6b1?
yes pretty sure i thought the change to 2.6 will stop the error from happening, but it's not how can i start troubleshooting?
Can you make really, absolutely sure? ;-) I'm not sure where to tell you to start troubleshooting because this kind of bug was supposed to be stamped out in 2.6. On Fri, 2002-10-04 at 13:00, Bakhtiar Abdul Hamid wrote:
On 4 Oct 2002, Chris McDonough wrote:
This is likely to happen under 2.5.1 but not 2.6b1. Are you sure you get the key error under 2.6b1?
yes pretty sure
i thought the change to 2.6 will stop the error from happening, but it's not
how can i start troubleshooting?
On 4 Oct 2002, Chris McDonough wrote:
Can you make really, absolutely sure? ;-) I'm not sure where to tell you to start troubleshooting because this kind of bug was supposed to be stamped out in 2.6.
well, ok i'm sure i can give you access to my zope2.6 instance for you to see the error_logs ;) btw, i'm on irc now and i've been searching for you for a few days :D
On Fri, 2002-10-04 at 13:00, Bakhtiar Abdul Hamid wrote:
On 4 Oct 2002, Chris McDonough wrote:
This is likely to happen under 2.5.1 but not 2.6b1. Are you sure you get the key error under 2.6b1?
yes pretty sure
i thought the change to 2.6 will stop the error from happening, but it's not
how can i start troubleshooting?
OK... is it predictable enough to come up with a repeatable test case? I can repeat it I can likely fix it. ;-) On Fri, 2002-10-04 at 13:43, Bakhtiar Abdul Hamid wrote:
On 4 Oct 2002, Chris McDonough wrote:
Can you make really, absolutely sure? ;-) I'm not sure where to tell you to start troubleshooting because this kind of bug was supposed to be stamped out in 2.6.
well, ok i'm sure
i can give you access to my zope2.6 instance for you to see the error_logs ;)
btw, i'm on irc now
and i've been searching for you for a few days :D
On Fri, 2002-10-04 at 13:00, Bakhtiar Abdul Hamid wrote:
On 4 Oct 2002, Chris McDonough wrote:
This is likely to happen under 2.5.1 but not 2.6b1. Are you sure you get the key error under 2.6b1?
yes pretty sure
i thought the change to 2.6 will stop the error from happening, but it's not
how can i start troubleshooting?
participants (3)
-
Bakhtiar A Hamid -
Bakhtiar Abdul Hamid -
Chris McDonough