Attachment 'supplementation.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3     MoinMoin - Action for supplementation pages
   4 
   5     This Action is used to create a supplementation subpage e.g. a Discussion page below a comon page
   6         
   7     Note:
   8     derived from the newpage macro by Vito Miliano (vito_moinnewpagewithtemplate@perilith.com) et al
   9 
  10     @copyright: 2006-2007 ReimarBauer  
  11     @license: GNU GPL, see COPYING for details.  
  12 """
  13 import StringIO
  14 from MoinMoin.Page import Page
  15 from MoinMoin import wikiutil
  16 from MoinMoin.wikiutil import quoteWikinameURL
  17 from MoinMoin.action import edit
  18 
  19 def execute(pagename, request):
  20     _ = request.getText
  21     sub_page_name = request.cfg.supplementation_page_name
  22     sub_page_template = request.cfg.supplementation_page_template
  23     newpagename = "%s/%s" % (pagename, sub_page_name)
  24 
  25     if pagename.endswith(sub_page_name): # sub_sub_page redirects to sub_page
  26         query = {}
  27         url = Page(request, pagename).url(request, query, escape=0, relative=False)
  28         request.http_redirect(url)
  29     elif request.user.may.read(newpagename) and request.user.may.write(newpagename):
  30         query = {}
  31         url = Page(request, newpagename).url(request, query, escape=0, relative=False)
  32         page = Page(request, newpagename)
  33         if page.exists(): # page is defined -> redirect
  34             pagecontent = page.get_raw_body()
  35             from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
  36             request.emit_http_headers()
  37             request.setContentLanguage(request.lang)
  38             request.theme.send_title(_("Discussion of %s") % pagename, pagename=newpagename)
  39             # Start content - IMPORTANT - without content div, there is no direction support!
  40             request.write(request.formatter.startContent("content"))
  41             parser = WikiParser(pagecontent, request)
  42             request.formatter.setPage(page)
  43             parser.format(request.formatter)
  44             request.theme.send_footer(newpagename)
  45             request.theme.send_closing_html()
  46         else:  # page will be created from template
  47             edit.execute(newpagename, request)

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2006-08-25 14:32:36, 1.5 KB) [[attachment:Discussion.py]]
  • [get | view] (2006-08-27 23:37:26, 5.6 KB) [[attachment:complete_discussion_patch.txt]]
  • [get | view] (2006-12-02 10:28:16, 3.7 KB) [[attachment:edit_bar.png]]
  • [get | view] (2007-01-10 20:46:57, 0.6 KB) [[attachment:editsupplementation.py]]
  • [get | view] (2006-08-26 16:54:52, 23.9 KB) [[attachment:proposal_buttom.png]]
  • [get | view] (2006-08-26 16:55:05, 21.2 KB) [[attachment:proposal_item.png]]
  • [get | view] (2006-08-26 16:55:18, 103.4 KB) [[attachment:proposal_menu.png]]
  • [get | view] (2006-08-26 16:55:29, 20.9 KB) [[attachment:proposal_tab.png]]
  • [get | view] (2007-01-10 20:46:43, 2.1 KB) [[attachment:supplementation.py]]
  • [get | view] (2006-12-02 10:11:48, 5.5 KB) [[attachment:supplementation_20061202_patch.txt]]
  • [get | view] (2006-08-31 11:03:34, 5.8 KB) [[attachment:supplementation_page_patch.txt]]
  • [get | view] (2007-01-10 20:48:51, 0.9 KB) [[attachment:theme_patch.txt]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.