changeset 3101:65322abb0a33

Fix trail for anon users without a session, do not show a single page. (ported from 1.6)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 23 Feb 2008 15:18:23 +0100
parents 55e47727656f
children a78bf6977df8
files MoinMoin/user.py
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/user.py	Sat Feb 23 15:11:48 2008 +0100
+++ b/MoinMoin/user.py	Sat Feb 23 15:18:23 2008 +0100
@@ -906,21 +906,23 @@
     # -----------------------------------------------------------------
     # Trail
 
+    def _wantTrail(self):
+        return (not self.valid and self._request.session != {}  # anon session
+                or self.valid and (self.show_page_trail or self.remember_last_visit))  # logged-in session
+
     def addTrail(self, page):
         """ Add page to trail.
 
         @param page: the page (object) to add to the trail
         """
-        if not self.valid or self.show_page_trail or self.remember_last_visit:
+        if self._wantTrail():
             # load trail if not known
             self.getTrail()
 
             pagename = page.page_name
             # Add only existing pages that the user may read
-            if self._request:
-                if not (page.exists() and
-                        self._request.user.may.read(pagename)):
-                    return
+            if not (page.exists() and self._request.user.may.read(pagename)):
+                return
 
             # Save interwiki links internally
             if self._cfg.interwikiname:
@@ -947,8 +949,7 @@
         @rtype: list
         @return: pages in trail
         """
-        if not self._trail and (
-           not self.valid or self.show_page_trail or self.remember_last_visit):
+        if not self._trail and self._wantTrail():
             trail = self._request.session.get('trail', [])
             trail = [t.strip() for t in trail]
             trail = [t for t in trail if t]