annotate MoinMoin/macro/EditTemplates.py @ 3229:09657fbd4aa2

converted to arg parser
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 09 Mar 2008 19:51:01 +0100
parents b06ef2a53efa
children 124d0ef138aa
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3 MoinMoin - Create an action link
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1791
diff changeset
5 @copyright: 2004 Johannes Berg <johannes@sipsolutions.de>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
6 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
7 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
8
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
9 Dependencies = ["language"]
3229
09657fbd4aa2 converted to arg parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1920
diff changeset
10 def macro_EditTemplates(macro):
1679
d6b93908e4d9 save CPU and disk I/O by checking for spiders in LikePages and EditTemplates macro, both used on MissingPage (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1549
diff changeset
11 result = ''
d6b93908e4d9 save CPU and disk I/O by checking for spiders in LikePages and EditTemplates macro, both used on MissingPage (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1549
diff changeset
12 # we don't want to spend much CPU for spiders requesting nonexisting pages
3229
09657fbd4aa2 converted to arg parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1920
diff changeset
13 if not macro.request.isSpiderAgent:
1679
d6b93908e4d9 save CPU and disk I/O by checking for spiders in LikePages and EditTemplates macro, both used on MissingPage (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1549
diff changeset
14 # Get list of template pages readable by current user
3229
09657fbd4aa2 converted to arg parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1920
diff changeset
15 filterfn = macro.request.cfg.cache.page_template_regex.search
09657fbd4aa2 converted to arg parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1920
diff changeset
16 templates = macro.request.rootpage.getPageList(filter=filterfn)
1679
d6b93908e4d9 save CPU and disk I/O by checking for spiders in LikePages and EditTemplates macro, both used on MissingPage (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1549
diff changeset
17 result = []
d6b93908e4d9 save CPU and disk I/O by checking for spiders in LikePages and EditTemplates macro, both used on MissingPage (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1549
diff changeset
18 if templates:
d6b93908e4d9 save CPU and disk I/O by checking for spiders in LikePages and EditTemplates macro, both used on MissingPage (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1549
diff changeset
19 templates.sort()
3229
09657fbd4aa2 converted to arg parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1920
diff changeset
20 page = macro.formatter.page
1679
d6b93908e4d9 save CPU and disk I/O by checking for spiders in LikePages and EditTemplates macro, both used on MissingPage (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1549
diff changeset
21 # send list of template pages
3229
09657fbd4aa2 converted to arg parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1920
diff changeset
22 result.append(macro.formatter.bullet_list(1))
1679
d6b93908e4d9 save CPU and disk I/O by checking for spiders in LikePages and EditTemplates macro, both used on MissingPage (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1549
diff changeset
23 for template in templates:
3229
09657fbd4aa2 converted to arg parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1920
diff changeset
24 result.append(macro.formatter.listitem(1))
09657fbd4aa2 converted to arg parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1920
diff changeset
25 result.append(page.link_to(macro.request, template, querystr={'action': 'edit', 'template': template}))
09657fbd4aa2 converted to arg parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1920
diff changeset
26 result.append(macro.formatter.listitem(0))
09657fbd4aa2 converted to arg parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1920
diff changeset
27 result.append(macro.formatter.bullet_list(0))
1679
d6b93908e4d9 save CPU and disk I/O by checking for spiders in LikePages and EditTemplates macro, both used on MissingPage (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1549
diff changeset
28 result = ''.join(result)
d6b93908e4d9 save CPU and disk I/O by checking for spiders in LikePages and EditTemplates macro, both used on MissingPage (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1549
diff changeset
29 return result
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
30