Attachment 'IncludeVal.py'

Download

   1 # -*- coding: utf-8 -*-
   2 """
   3     MoinMoin - macro to overlay data on a template
   4 
   5     <<IncludeVal(key)>>
   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_IncludeVal(macro, pagekey=u'', input=u'text'):
  16     request = macro.request
  17     _ = request.getText
  18 
  19     # parse and check arguments
  20     if not pagekey:
  21         return (_sysmsg % ('error', _('Invalid key arguments "%s"!')) % (pagekey, ))
  22     if not hasattr(request, 'ReqVars') or not request.ReqVars.has_key('vardict'):
  23         # Macro not called from a page included with IncludeWithVars
  24         return u'<b>Var: %s</b>' % pagekey
  25 
  26     m = Macro(macro.parser)
  27     if request.args.has_key('edit'):
  28         input = u'<input type="text" name="%s" value="%s" />'
  29         return input % (pagekey, m.macro_GetVal(request.ReqVars['vardict'], pagekey))
  30     else:
  31         return m.macro_GetVal(request.ReqVars['vardict'], pagekey)

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] (2013-03-03 18:20:33, 34.3 KB) [[attachment:COPYING]]
  • [get | view] (2013-03-03 18:21:12, 1.0 KB) [[attachment:IncludeVal.py]]
  • [get | view] (2013-03-03 18:21:23, 1.3 KB) [[attachment:IncludeWithVals.py]]
  • [get | view] (2013-03-03 18:20:49, 2.3 KB) [[attachment:savedict.py]]
 All files | Selected Files: delete move to page copy to page

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