comparison roundup/cgi/client.py @ 1414:b4630d078c08

another attempt to fix cookie misbehaviour
author Richard Jones <richard@users.sourceforge.net>
date Fri, 07 Feb 2003 04:49:13 +0000
parents 8dc60d87ab42
children 472c21af7f69
comparison
equal deleted inserted replaced
1413:4ae9d725bec4 1414:b4630d078c08
1 # $Id: client.py,v 1.76 2003-02-06 05:43:47 richard Exp $ 1 # $Id: client.py,v 1.77 2003-02-07 04:49:13 richard Exp $
2 2
3 __doc__ = """ 3 __doc__ = """
4 WWW request handler (also used in the stand-alone server). 4 WWW request handler (also used in the stand-alone server).
5 """ 5 """
6 6
93 self.base = self.instance.config.TRACKER_WEB 93 self.base = self.instance.config.TRACKER_WEB
94 94
95 # this is the "cookie path" for this tracker (ie. the path part of 95 # this is the "cookie path" for this tracker (ie. the path part of
96 # the "base" url) 96 # the "base" url)
97 self.cookie_path = urlparse.urlparse(self.base)[2] 97 self.cookie_path = urlparse.urlparse(self.base)[2]
98 self.cookie_name = 'roundup_session_' + re.sub('[^a-zA-Z]', '',
99 self.instance.config.TRACKER_NAME)
98 100
99 # see if we need to re-parse the environment for the form (eg Zope) 101 # see if we need to re-parse the environment for the form (eg Zope)
100 if form is None: 102 if form is None:
101 self.form = cgi.FieldStorage(environ=env) 103 self.form = cgi.FieldStorage(environ=env)
102 else: 104 else:
225 # look up the user session cookie 227 # look up the user session cookie
226 cookie = Cookie.Cookie(self.env.get('HTTP_COOKIE', '')) 228 cookie = Cookie.Cookie(self.env.get('HTTP_COOKIE', ''))
227 user = 'anonymous' 229 user = 'anonymous'
228 230
229 # bump the "revision" of the cookie since the format changed 231 # bump the "revision" of the cookie since the format changed
230 if (cookie.has_key('roundup_user_2') and 232 if (cookie.has_key(self.cookie_name) and
231 cookie['roundup_user_2'].value != 'deleted'): 233 cookie[self.cookie_name].value != 'deleted'):
232 234
233 # get the session key from the cookie 235 # get the session key from the cookie
234 self.session = cookie['roundup_user_2'].value 236 self.session = cookie[self.cookie_name].value
235 # get the user from the session 237 # get the user from the session
236 try: 238 try:
237 # update the lifetime datestamp 239 # update the lifetime datestamp
238 sessions.set(self.session, last_use=time.time()) 240 sessions.set(self.session, last_use=time.time())
239 sessions.commit() 241 sessions.commit()
484 # expire us in a long, long time 486 # expire us in a long, long time
485 expire = Cookie._getdate(86400*365) 487 expire = Cookie._getdate(86400*365)
486 488
487 # generate the cookie path - make sure it has a trailing '/' 489 # generate the cookie path - make sure it has a trailing '/'
488 self.additional_headers['Set-Cookie'] = \ 490 self.additional_headers['Set-Cookie'] = \
489 'roundup_user_2=%s; expires=%s; Path=%s;'%(self.session, expire, 491 '%s=%s; expires=%s; Path=%s;'%(self.cookie_name, self.session,
490 self.cookie_path) 492 expire, self.cookie_path)
491 493
492 def make_user_anonymous(self): 494 def make_user_anonymous(self):
493 ''' Make us anonymous 495 ''' Make us anonymous
494 496
495 This method used to handle non-existence of the 'anonymous' 497 This method used to handle non-existence of the 'anonymous'
581 self.make_user_anonymous() 583 self.make_user_anonymous()
582 584
583 # construct the logout cookie 585 # construct the logout cookie
584 now = Cookie._getdate() 586 now = Cookie._getdate()
585 self.additional_headers['Set-Cookie'] = \ 587 self.additional_headers['Set-Cookie'] = \
586 'roundup_user_2=deleted; Max-Age=0; expires=%s; Path=%s;'%(now, 588 '%s=deleted; Max-Age=0; expires=%s; Path=%s;'%(self.cookie_name,
587 self.cookie_path) 589 now, self.cookie_path)
588 590
589 # Let the user know what's going on 591 # Let the user know what's going on
590 self.ok_message.append(_('You are logged out')) 592 self.ok_message.append(_('You are logged out'))
591 593
592 def registerAction(self): 594 def registerAction(self):

Roundup Issue Tracker: http://roundup-tracker.org/