changeset 1935:740d9939ffe9

use session object to store page trail (even for anon users, if anon sessions are enabled)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 03 Apr 2007 23:46:32 +0200
parents 1040f23023a9
children adcdb9cc9258 d7296d36e6f0
files MoinMoin/auth/__init__.py MoinMoin/theme/__init__.py MoinMoin/user.py
diffstat 3 files changed, 9 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth/__init__.py	Tue Apr 03 18:48:59 2007 +0200
+++ b/MoinMoin/auth/__init__.py	Tue Apr 03 23:46:32 2007 +0200
@@ -171,6 +171,9 @@
         else:
             self.ce.update(self._data)
 
+    def get(self, name, default):
+        return self._data.get(name, default)
+
     def delete(self):
         if self.ce.exists():
             self.ce.remove()
--- a/MoinMoin/theme/__init__.py	Tue Apr 03 18:48:59 2007 +0200
+++ b/MoinMoin/theme/__init__.py	Tue Apr 03 23:46:32 2007 +0200
@@ -579,7 +579,7 @@
         request = self.request
         user = request.user
         html = ''
-        if user.valid and user.show_page_trail:
+        if not user.valid or user.show_page_trail:
             trail = user.getTrail()
             if trail:
                 items = []
--- a/MoinMoin/user.py	Tue Apr 03 18:48:59 2007 +0200
+++ b/MoinMoin/user.py	Tue Apr 03 23:46:32 2007 +0200
@@ -824,7 +824,7 @@
         # TODO: acquire lock here, so multiple processes don't clobber
         # each one trail.
 
-        if self.valid and (self.show_page_trail or self.remember_last_visit):
+        if not self.valid or self.show_page_trail or self.remember_last_visit:
             # load trail if not known
             self.getTrail()
 
@@ -858,16 +858,7 @@
         Save using one write call, which should be fine in most cases,
         but will fail in rare cases without real file locking.
         """
-        data = '\n'.join(self._trail) + '\n'
-        path = self.__filename() + ".trail"
-        try:
-            f = codecs.open(path, "w", config.charset)
-            try:
-                f.write(data)
-            finally:
-                f.close()
-        except (IOError, OSError), err:
-            self._request.log("Can't save trail file: %s" % str(err))
+        self._request.session['trail'] = self._trail
 
     def getTrail(self):
         """ Return list of recently visited pages.
@@ -875,13 +866,9 @@
         @rtype: list
         @return: pages in trail
         """
-        if self.valid and (self.show_page_trail or self.remember_last_visit) \
-                and not self._trail \
-                and os.path.exists(self.__filename() + ".trail"):
-            try:
-                trail = codecs.open(self.__filename() + ".trail", 'r', config.charset).readlines()
-            except (OSError, ValueError):
-                trail = []
+        if not self._trail and (
+           not self.valid or self.show_page_trail or self.remember_last_visit):
+            trail = self._request.session.get('trail', [])
             trail = [t.strip() for t in trail]
             trail = [t for t in trail if t]
             self._trail = trail[-self._cfg.trail_size:]