annotate MoinMoin/action/supplementation.py @ 1743:00ffe1ab1c8b

supplementation: minor optimizations
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 14 Jan 2007 00:49:54 +0100
parents e9813bc43544
children 4a31739bc6e1
rev   line source
1732
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
2 """
1743
00ffe1ab1c8b supplementation: minor optimizations
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1732
diff changeset
3 MoinMoin - This Action is used to create a supplementation subpage e.g. a Discussion page below a comon page
1732
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
4
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
5 Note:
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
6 derived from the newpage macro by Vito Miliano (vito_moinnewpagewithtemplate@perilith.com) et al
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
7
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
8 @copyright: 2006-2007 ReimarBauer
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
9 @license: GNU GPL, see COPYING for details.
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
10 """
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
11 from MoinMoin.Page import Page
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
12 from MoinMoin.wikiutil import quoteWikinameURL
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
13
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
14 def execute(pagename, request):
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
15 _ = request.getText
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
16 sub_page_name = request.cfg.supplementation_page_name
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
17 sub_page_template = request.cfg.supplementation_page_template
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
18 newpagename = "%s/%s" % (pagename, sub_page_name)
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
19
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
20 if pagename.endswith(sub_page_name): # sub_sub_page redirects to sub_page
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
21 query = {}
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
22 url = Page(request, pagename).url(request, query, escape=0, relative=False)
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
23 request.http_redirect(url)
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
24 elif request.user.may.read(newpagename) and request.user.may.write(newpagename):
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
25 query = {}
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
26 url = Page(request, newpagename).url(request, query, escape=0, relative=False)
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
27 test = Page(request, newpagename)
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
28 if test.exists(): # page is defined -> redirect
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
29 request.http_redirect(url)
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
30 else: # page will be created from template
1743
00ffe1ab1c8b supplementation: minor optimizations
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1732
diff changeset
31 query = {'action': 'edit', 'backto': newpagename, 'template': quoteWikinameURL(sub_page_template)}
1732
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
32 url = Page(request, newpagename).url(request, query, escape=0, relative=False)
e9813bc43544 supplementation: Action for supplementation pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
33 request.http_redirect(url)