changeset 451:f264539ad649

fixed logout problems when using cfg.cookie_path imported from: moin--main--1.5--patch-455
author Thomas Waldmann <tw@waldmann-edv.de>
date Mon, 20 Feb 2006 09:24:06 +0000
parents 215d66f88732
children 738fdb628b4e
files ChangeLog MoinMoin/request.py docs/CHANGES
diffstat 3 files changed, 40 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Feb 18 16:58:21 2006 +0000
+++ b/ChangeLog	Mon Feb 20 09:24:06 2006 +0000
@@ -2,6 +2,20 @@
 # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5
 #
 
+2006-02-20 10:24:06 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-455
+
+    Summary:
+      fixed logout problems when using cfg.cookie_path
+    Revision:
+      moin--main--1.5--patch-455
+
+    fixed logout problems when using cfg.cookie_path
+    
+
+    modified files:
+     ChangeLog MoinMoin/request.py docs/CHANGES
+
+
 2006-02-18 17:58:21 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-454
 
     Summary:
--- a/MoinMoin/request.py	Sat Feb 18 16:58:21 2006 +0000
+++ b/MoinMoin/request.py	Mon Feb 20 09:24:06 2006 +0000
@@ -1283,7 +1283,22 @@
         # Set Pragma for http 1.0 caches
         # See http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc2068.html#sec-14.32
         self.setHttpHeader('Pragma: no-cache')
-       
+
+    def makeCookie(self, moin_id, maxage, expires):
+        from Cookie import SimpleCookie
+        c = SimpleCookie()
+        c['MOIN_ID'] = moin_id
+        c['MOIN_ID']['max-age'] = maxage
+        if self.cfg.cookie_domain:
+            c['MOIN_ID']['domain'] = self.cfg.cookie_domain
+        if self.cfg.cookie_path:
+            c['MOIN_ID']['path'] = self.cfg.cookie_path
+        else:
+            c['MOIN_ID']['path'] = self.getScriptname()
+        # Set expires for older clients
+        c['MOIN_ID']['expires'] = self.httpDate(when=expires, rfc='850')        
+        return c.output()
+        
     def setCookie(self):
         """ Set cookie for the current user
         
@@ -1311,23 +1326,11 @@
             maxage = (-lifetime)
         expires = now + maxage
         
-        # Set the cookie
-        from Cookie import SimpleCookie
-        c = SimpleCookie()
-        c['MOIN_ID'] = self.user.id
-        c['MOIN_ID']['max-age'] = maxage
-        if self.cfg.cookie_domain:
-            c['MOIN_ID']['domain'] = self.cfg.cookie_domain
-        if self.cfg.cookie_path:
-            c['MOIN_ID']['path'] = self.cfg.cookie_path
-        else:
-            c['MOIN_ID']['path'] = self.getScriptname()
-        # Set expires for older clients
-        c['MOIN_ID']['expires'] = self.httpDate(when=expires, rfc='850')        
-        self.setHttpHeader(c.output())
+        cookie = self.makeCookie(self.user.id, maxage, expires)
+        self.setHttpHeader(cookie)
 
         # Update the saved cookie, so other code works with new setup
-        self.saved_cookie = c.output()
+        self.saved_cookie = cookie
 
         # IMPORTANT: Prevent caching of current page and cookie
         self.disableHttpCaching()
@@ -1342,18 +1345,13 @@
         Finally, delete the saved cookie and create a new user based on
         the new settings.
         """
+        moin_id = ''
+        maxage = 0
+        # Set expires to one year ago for older clients
+        expires = time.time() - (3600 * 24 * 365) # 1 year ago
+        cookie = self.makeCookie(moin_id, maxage, expires) 
         # Set cookie
-        from Cookie import SimpleCookie
-        c = SimpleCookie()
-        c['MOIN_ID'] = ''
-        if self.cfg.cookie_domain:
-            c['MOIN_ID']['domain'] = self.cfg.cookie_domain
-        c['MOIN_ID']['path'] = self.getScriptname()
-        c['MOIN_ID']['max-age'] = 0
-        # Set expires to one year ago for older clients
-        yearago = time.time() - (3600 * 24 * 365)
-        c['MOIN_ID']['expires'] = self.httpDate(when=yearago, rfc='850')
-        self.setHttpHeader(c.output())
+        self.setHttpHeader(cookie)
 
         # Update saved cookie and set new unregistered user
         self.saved_cookie = ''
--- a/docs/CHANGES	Sat Feb 18 16:58:21 2006 +0000
+++ b/docs/CHANGES	Mon Feb 20 09:24:06 2006 +0000
@@ -54,6 +54,7 @@
       that time or not. This has been changed, we update the cookie expiry now
       on every request, so it will expire cookie_lifetime after your last
       request (not after login).
+    * fixed logout problems when using cfg.cookie_path
     * lupy search now behaves a bit less curious. Still no guarantees...
     * we lowered the twisted server timeout to 2 minutes now (was: 10) because
       it just used up too many files (open TCP connections until it timeouts)