changeset 1732:e9813bc43544

supplementation: Action for supplementation pages
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 09 Jan 2007 21:55:04 +0100
parents d4a424079d50
children d97b403ff6b9
files MoinMoin/action/supplementation.py
diffstat 1 files changed, 36 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/action/supplementation.py	Tue Jan 09 21:55:04 2007 +0100
@@ -0,0 +1,36 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - Action for supplementation pages
+
+    This Action is used to create a supplementation subpage e.g. a Discussion page below a comon page
+        
+    Note:
+    derived from the newpage macro by Vito Miliano (vito_moinnewpagewithtemplate@perilith.com) et al
+
+    @copyright: 2006-2007 ReimarBauer  
+    @license: GNU GPL, see COPYING for details.  
+"""
+from MoinMoin.Page import Page
+from MoinMoin.wikiutil import quoteWikinameURL
+
+def execute(pagename, request):
+    _ = request.getText
+    sub_page_name = request.cfg.supplementation_page_name
+    sub_page_template = request.cfg.supplementation_page_template
+    newpagename = "%s/%s" % (pagename, sub_page_name)
+
+    if pagename.endswith(sub_page_name): # sub_sub_page redirects to sub_page
+        query = {}
+        url = Page(request, pagename).url(request, query, escape=0, relative=False)
+        request.http_redirect(url)
+    elif request.user.may.read(newpagename) and request.user.may.write(newpagename):
+        query = {}
+        url = Page(request, newpagename).url(request, query, escape=0, relative=False)
+        test = Page(request, newpagename)
+        if test.exists(): # page is defined -> redirect
+            request.http_redirect(url)
+        else:  # page will be created from template
+            query = {'action': 'edit', 'backto': newpagename}
+            query['template'] = quoteWikinameURL(sub_page_template)
+            url = Page(request, newpagename).url(request, query, escape=0, relative=False)
+            request.http_redirect(url)