Back to index

moin  1.9.0~rc2
supplementation.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin -  This Action is used to create a supplementation subpage e.g. a Discussion page below a comon page
00004 
00005     Note:
00006     derived from the newpage macro by Vito Miliano (vito_moinnewpagewithtemplate@perilith.com) et al
00007 
00008     @copyright: 2006-2007 MoinMoin:ReimarBauer
00009     @license: GNU GPL, see COPYING for details.
00010 """
00011 from MoinMoin.Page import Page
00012 from MoinMoin.wikiutil import quoteWikinameURL
00013 
00014 def execute(pagename, request):
00015     _ = request.getText
00016     sub_page_name = request.cfg.supplementation_page_name
00017     sub_page_template = request.cfg.supplementation_page_template
00018     newpagename = "%s/%s" % (pagename, sub_page_name)
00019     errormsg = _("You are not allowed to create the supplementation page.")
00020 
00021     if pagename.endswith(sub_page_name): # sub_sub_page redirects to sub_page
00022         query = {}
00023         url = Page(request, pagename).url(request, query)
00024         request.http_redirect(url)
00025     elif request.user.may.read(newpagename):
00026         query = {}
00027         url = Page(request, newpagename).url(request, query)
00028         test = Page(request, newpagename)
00029         if test.exists(): # page is defined -> redirect
00030             request.http_redirect(url)
00031         elif request.user.may.write(newpagename):  # page will be created from template
00032             query = {'action': 'edit', 'backto': newpagename, 'template': quoteWikinameURL(sub_page_template)}
00033             url = Page(request, newpagename).url(request, query)
00034             request.http_redirect(url)
00035         else:
00036             request.theme.add_msg(errormsg, "error")
00037     else:
00038         request.theme.add_msg(errormsg, "error")
00039