Attachment 'IncludeWithVals.py'
Download 1 # -*- coding: utf-8 -*-
2 """
3 MoinMoin - macro to overlay data on a template
4
5 <<IncludeWithVals(template, vardict)>>
6
7 @copyright: 2012 Gordon Messmer <gordon@dragonsdawn.net>
8 @license: GNU GPL, see COPYING for details.
9 """
10
11 from MoinMoin.macro import Macro
12
13 _sysmsg = u'<p><strong class="%s">%s</strong></p>'
14
15 def macro_IncludeWithVals(macro, template=u"", vardict=None):
16 request = macro.request
17 _ = request.getText
18
19 # parse and check arguments
20 if not template:
21 return (_sysmsg % ('error', _('Invalid include arguments "%s"!')) % (template, ))
22 if not hasattr(request, 'ReqVars'):
23 request.ReqVars = {}
24
25 this_page = macro.formatter.page.page_name
26 if vardict:
27 request.ReqVars['vardict'] = vardict
28 else:
29 request.ReqVars['vardict'] = this_page + 'Dict'
30
31 if request.args.has_key('edit'):
32 formtag = u'<form action="%s/%s?action=savedict" method="post">\n<input type="hidden" name="vardict" value="%s" />' % \
33 (request.script_root, this_page, request.ReqVars['vardict'])
34 formend = u'<input type="submit" value="%s" />\n</form>\n' % \
35 _('Save form values')
36 return formtag + Macro(macro.parser).execute('Include', template) + formend
37 else:
38 return Macro(macro.parser).execute('Include', template)
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.You are not allowed to attach a file to this page.