Victor Muslin
victor at prodigy.net
Tue Apr 17 08:25:04 EST 2001
I don't see where you are creating a dictionary entry with a key 'counter'. Therefore, the statement in the else clause: session_data['count'] = 0 will always be executed. Perhaps you want to say: if session_data.has_key('count'): At 04:32 PM 4/17/01 +0900, nineclue at bigfoot.com wrote: >Greetings... > >I've posted somewhat long python program during development, which >may need pg module, postgres running with pyweb db created etc... > >Here's short version, which don't work as I expected. > >from mod_python import apache > >session_data = {} >session_counter = 0 > >def handler(req): > global session_data, session_counter > > if session_data.has_key('counter'): > session_data['count'] = session_data['count'] + 1 > else: > session_data['count'] = 0 > > session_counter += 1 > req.write('<HTML>') > req.write('Session data has %d items<BR>' % len(session_data)) > req.write('Counter : %02d<BR>' % session_data['count']) > req.write('Alternative Counter : %02d<BR>' % session_counter) > req.write('</HTML>') > return apache.OK > >When I loaded the page and tried several reloads, session_data dictionary >variable is never increased and session_counter variable is increased >after several tries. What I expected was both variable increase at each >reload. > >In my thoughts, dictionary variable is not supported and main interpreter >is created in each Apache processes, which is shared by subinterpreters. > >Sorry for posting again, long message and my poor English. > >Thanks in advance. > >_______________________________________________ >Mod_python mailing list >Mod_python at modpython.org >http://www.modpython.org/mailman/listinfo/mod_python __________________________________________________________________________________ Victor Muslin The power of accurate observation is frequently called cynicism by those who don't have it. - George Bernard Shaw -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.modpython.org/pipermail/mod_python/attachments/20010417/01836390/attachment-0003.htm
|