Attachment 'parser_template.py'

Download

   1 # -*- coding: UTF8 -*-
   2 """
   3     MoinMoin - ... action
   4 
   5     Allows to ... .
   6 
   7     @copyright: 20??-20?? Autho Name <author@url.org>,
   8     @license: GNU GPL, see COPYING for details.
   9 """
  10 
  11 from MoinMoin import wikiutil
  12 from MoinMoin.Page import Page
  13 from MoinMoin.parser.text_moin_wiki import Parser as MoinParser
  14 
  15 
  16 class Parser:
  17     """
  18         Description
  19     """
  20     def __init__(self, wikitext, request, **kw):
  21         self.wikitext = wikitext
  22         self.request = request
  23         self.pagename = self.request.page.page_name
  24         self.formatter=self.request.formatter
  25         self.page = Page(self.request, self.pagename)
  26         self.pagepath=self.page.getPageBasePath()[1]
  27         self.url=self.request.href(self.request.page.page_name)
  28         self.url_full=self.request.getQualifiedURL(self.url)
  29         self.title = self.page.split_title()
  30         self.formargs=self.request.values
  31         arg_to_dict=wikiutil.importPlugin(self.request.cfg, 'macro', 'macro_template', 'arg_to_dict')
  32         self.parserargs=arg_to_dict(kw['format_args'])
  33     def format(self, formatter):
  34         """
  35             Send the "parsed" text.
  36         """
  37         moin_output="""
  38 == Page Information ==
  39  * Moin-Pagename: %s
  40  * Moin-Pagetitle: %s
  41  * Moin-Pagepath: %s
  42  * Page-Url: %s
  43  * Full Page-Url: %s
  44  
  45 == Url/ Form data ==
  46 """%(self.pagename, self.title, self.pagepath, self.url, self.url_full)
  47         for key in self.formargs.keys():
  48             moin_output+=u" * %s=%s\n"%(key, self.formargs.get(key))
  49         moin_output+="== Acl ==\n"
  50         if self.request.user.may.read(self.pagename):
  51             moin_output+=u" * You have read rights.\n"
  52         else:
  53             moin_output+=" * You don't have read rights.\n"
  54         if self.request.user.may.write(self.pagename):
  55             moin_output+=u" * You have write rights.\n"
  56         else:
  57             moin_output+=u" * You don't have write rights.\n"
  58         moin_output+="== Text to parse ==\n"
  59         moin_output+=u"{{{\n%s\n}}}\n"%(self.wikitext)
  60         moin_output+="== Parser Data ==\n"
  61         for key in self.parserargs.keys():
  62             moin_output+=u" * %s=%s\n"%(key, self.parserargs.get(key))
  63         parser=MoinParser(moin_output, self.request)
  64         parser.format(self.formatter)
  65         

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] (2012-01-12 21:16:36, 2.4 KB) [[attachment:action_template.py]]
  • [get | view] (2012-01-12 21:16:11, 2.4 KB) [[attachment:macro_template.py]]
  • [get | view] (2012-01-12 21:15:50, 2.2 KB) [[attachment:parser_template.py]]
  • [get | view] (2014-01-19 09:43:21, 11.2 KB) [[attachment:template.zip]]
  • [get | view] (2014-01-13 08:09:48, 10.1 KB) [[attachment:template_old.zip]]
 All files | Selected Files: delete move to page copy to page

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