changeset 5992:f8bb40fb3ac4

rss_rc action: optimize single page performance a lot
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 08 Jun 2013 03:45:14 +0200
parents e0dcce5a9abf
children 006b3a2ef9d9
files MoinMoin/action/rss_rc.py docs/CHANGES
diffstat 2 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/rss_rc.py	Sat Jun 08 02:31:32 2013 +0200
+++ b/MoinMoin/action/rss_rc.py	Sat Jun 08 03:45:14 2013 +0200
@@ -38,6 +38,17 @@
     else:
         return pagename == page_pattern
 
+def is_single_page_match(page_pattern):
+    # note: keep this code in sync with match_page()!
+    if not page_pattern:
+        return False
+    elif page_pattern[0] == "^":
+        return False
+    elif page_pattern.endswith("/"):
+        return False
+    else:
+        return True
+
 def execute(pagename, request):
     """ Send recent changes as an RSS document
     """
@@ -92,8 +103,11 @@
     except ValueError:
         pass
 
-    # get data
-    log = editlog.EditLog(request)
+    # if we are just interested in a specific page, using the local edit-log
+    # of that page is much faster than the global one - esp. if the page was
+    # NOT recently changed and the global edit-log is rather big.
+    kw = dict(rootpagename=page_pattern) if is_single_page_match(page_pattern) else {}
+    log = editlog.EditLog(request, **kw)
     logdata = []
     counter = 0
     pages = {}
--- a/docs/CHANGES	Sat Jun 08 02:31:32 2013 +0200
+++ b/docs/CHANGES	Sat Jun 08 03:45:14 2013 +0200
@@ -54,6 +54,11 @@
     logged-in users if the language identifier there was (partially) uppercase.
   * fix Python 2.7.4/5 compatibility issue with rss_rc action using handler._out
 
+  Other changes:
+  * rss_rc action (RSS feed) is now much faster / much less resource consuming
+    when requested for a specific single page. As we have a link to this in
+    every page's html output, this likely also lightens the load caused by bots
+    and search engine crawlers.
 
 Version 1.9.7:
   New features: