comparison MoinMoin/action/rss_rc.py @ 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 aee4ff651134
children 6de72050e1b9
comparison
equal deleted inserted replaced
5991:e0dcce5a9abf 5992:f8bb40fb3ac4
36 return (pagename == page_pattern[:-1]) or \ 36 return (pagename == page_pattern[:-1]) or \
37 pagename.startswith(page_pattern) 37 pagename.startswith(page_pattern)
38 else: 38 else:
39 return pagename == page_pattern 39 return pagename == page_pattern
40 40
41 def is_single_page_match(page_pattern):
42 # note: keep this code in sync with match_page()!
43 if not page_pattern:
44 return False
45 elif page_pattern[0] == "^":
46 return False
47 elif page_pattern.endswith("/"):
48 return False
49 else:
50 return True
51
41 def execute(pagename, request): 52 def execute(pagename, request):
42 """ Send recent changes as an RSS document 53 """ Send recent changes as an RSS document
43 """ 54 """
44 if not wikixml.ok: 55 if not wikixml.ok:
45 request.mimetype = 'text/plain' 56 request.mimetype = 'text/plain'
90 try: 101 try:
91 page_pattern = request.values.get('page', page_pattern) 102 page_pattern = request.values.get('page', page_pattern)
92 except ValueError: 103 except ValueError:
93 pass 104 pass
94 105
95 # get data 106 # if we are just interested in a specific page, using the local edit-log
96 log = editlog.EditLog(request) 107 # of that page is much faster than the global one - esp. if the page was
108 # NOT recently changed and the global edit-log is rather big.
109 kw = dict(rootpagename=page_pattern) if is_single_page_match(page_pattern) else {}
110 log = editlog.EditLog(request, **kw)
97 logdata = [] 111 logdata = []
98 counter = 0 112 counter = 0
99 pages = {} 113 pages = {}
100 lastmod = 0 114 lastmod = 0
101 for line in log.reverse(): 115 for line in log.reverse():