Expand variables in page edit form when load contents from template.

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