Attachment 'PreloadVariables_0.1.patch'

Download

   1 Expand variables in page edit form when load contents from template.
   2 
   3 diff -r 0865ccb99181 MoinMoin/PageEditor.py
   4 --- a/MoinMoin/PageEditor.py	Wed Nov 19 10:25:14 2008 +0800
   5 +++ b/MoinMoin/PageEditor.py	Wed Nov 19 10:25:16 2008 +0800
   6 @@ -281,6 +281,9 @@
   7              template_page = wikiutil.unquoteWikiname(form['template'][0])
   8              if request.user.may.read(template_page):
   9                  raw_body = Page(request, template_page).get_raw_body()
  10 +                # OSSXP: expand variables in page edit form when load contents from template.
  11 +                if not wikiutil.isTemplatePage(request, self.page_name):
  12 +                    raw_body = self._expand_variables(raw_body)
  13                  if raw_body:
  14                      request.theme.add_msg(_("[Content of new page loaded from %s]") % (template_page, ), 'info')
  15                  else:
  16 @@ -795,7 +798,7 @@
  17  
  18          return time.strftime("%Y-%m-%dT%H:%M:%S", timefuncs.tmtuple(now)) + zone
  19  
  20 -    def _expand_variables(self, text):
  21 +    def _expand_variables(self, text, preload=False):
  22          """ Expand @VARIABLE@ in `text`and return the expanded text.
  23  
  24          @param text: current text of wikipage
  25 @@ -830,7 +833,12 @@
  26              userDictPage = u.name + "/MyDict"
  27              if request.dicts.has_dict(userDictPage):
  28                  variables.update(request.dicts.dict(userDictPage))
  29 -
  30 +        # OSSXP: expand variables in page edit form when load contents from template.
  31 +        if preload:
  32 +            variables['SIG'] = "-- %s @TIME@" % signature
  33 +            for name in ['TIME','DATE']:
  34 +                if variables.has_key(name):
  35 +                    del variables[name]
  36          for name in variables:
  37              text = text.replace('@%s@' % name, variables[name])
  38          return text

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] (2008-11-23 12:46:59, 1.7 KB) [[attachment:PreloadVariables_0.1.patch]]
 All files | Selected Files: delete move to page copy to page

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