changeset 1956:477760dd8487

speedup addTrail by passing existing page object
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 07 Apr 2007 00:13:11 +0200
parents c872387196da
children a923b1df9dac
files MoinMoin/Page.py MoinMoin/PageEditor.py MoinMoin/user.py
diffstat 3 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Fri Apr 06 23:33:36 2007 +0200
+++ b/MoinMoin/Page.py	Sat Apr 07 00:13:11 2007 +0200
@@ -1102,7 +1102,7 @@
                 # Page trail
                 trail = None
                 if not print_mode:
-                    request.user.addTrail(self.page_name)
+                    request.user.addTrail(self)
                     trail = request.user.getTrail()
 
                 title = self.split_title()
--- a/MoinMoin/PageEditor.py	Fri Apr 06 23:33:36 2007 +0200
+++ b/MoinMoin/PageEditor.py	Sat Apr 07 00:13:11 2007 +0200
@@ -1150,7 +1150,7 @@
             # Update page trail with the page we just saved.
             # This is needed for NewPage macro with backto because it does not
             # send the page we just saved.
-            request.user.addTrail(self.page_name)
+            request.user.addTrail(self)
 
         # remove lock (forcibly if we were allowed to break it by the UI)
         # !!! this is a little fishy, since the lock owner might not notice
--- a/MoinMoin/user.py	Fri Apr 06 23:33:36 2007 +0200
+++ b/MoinMoin/user.py	Sat Apr 07 00:13:11 2007 +0200
@@ -853,10 +853,10 @@
     # -----------------------------------------------------------------
     # Trail
 
-    def addTrail(self, pagename):
+    def addTrail(self, page):
         """ Add page to trail.
         
-        @param pagename: the page name to add to the trail
+        @param page: the page (object) to add to the trail
         """
         # TODO: acquire lock here, so multiple processes don't clobber
         # each one trail.
@@ -865,12 +865,11 @@
             # load trail if not known
             self.getTrail()
 
+            pagename = page.page_name
             # Add only existing pages that the user may read
             if self._request:
-                from MoinMoin.Page import Page
-                page = Page(self._request, pagename)
                 if not (page.exists() and
-                        self._request.user.may.read(page.page_name)):
+                        self._request.user.may.read(pagename)):
                     return
 
             # Save interwiki links internally