comparison MoinMoin/macro/RandomPage.py @ 950:4eb66637ccd0

whitespace-only cleanup, small style changes
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 17 Jul 2006 04:27:24 +0200
parents 77665d8e2254
children bb2e053067fb
comparison
equal deleted inserted replaced
949:cbbde07e00c4 950:4eb66637ccd0
13 13
14 Dependencies = ["time"] 14 Dependencies = ["time"]
15 15
16 def execute(macro, args): 16 def execute(macro, args):
17 request = macro.request 17 request = macro.request
18 18
19 # get number of wanted links 19 # get number of wanted links
20 try: 20 try:
21 links = max(int(args), 1) 21 links = max(int(args), 1)
22 except StandardError: 22 except StandardError:
23 links = 1 23 links = 1
31 found = 0 31 found = 0
32 while found < links and all_pages: 32 while found < links and all_pages:
33 # Take one random page from the list 33 # Take one random page from the list
34 pagename = random.choice(all_pages) 34 pagename = random.choice(all_pages)
35 all_pages.remove(pagename) 35 all_pages.remove(pagename)
36 36
37 # Filter out deleted pages or pages the user may not read. 37 # Filter out deleted pages or pages the user may not read.
38 page = Page(request, pagename) 38 page = Page(request, pagename)
39 if page.exists() and request.user.may.read(pagename): 39 if page.exists() and request.user.may.read(pagename):
40 pages.append(pagename) 40 pages.append(pagename)
41 found += 1 41 found += 1
42 42
43 if not pages: 43 if not pages:
44 return '' 44 return ''
45 45
46 f = macro.formatter 46 f = macro.formatter
47 47