[Moin-user] Builtin variable for new revision?

Greg Ward gerg.ward+moin at gmail.com
Tue Oct 21 10:42:39 EDT 2008


I would like to propose a new builtin variable, @REVISION@,
which would contain the revision number that will be created by this
"Edit" action.  You could use to add something like

  Revision @REVISION@ approved by @USERNAME at .

...which really means that @USERNAME@ is approving the version including
his edits, which I think is fine.

This is *tentative*: I'm not sure I will need it, but it was so easy to
write the patch that I just did it in 10 minutes.  So I'm going to play
around with it and see if it is useful for me.  If so, I will try to get
it merged upstream.  Thought I would share the idea here and see if
anyone else thinks it would be useful.  I will attach my patch (relative
to moin/1.8 branch).

        Greg
-------------- next part --------------
diff -r 4186e90ead06 MoinMoin/PageEditor.py
--- a/MoinMoin/PageEditor.py	Sat Oct 04 23:16:54 2008 +0200
+++ b/MoinMoin/PageEditor.py	Tue Oct 21 10:41:13 2008 -0400
@@ -775,7 +775,8 @@
             'USERNAME': signature,
             'USER': "-- %s" % signature,
             'SIG': "-- %s <<DateTime(%s)>>" % (signature, now),
-            'EMAIL': "<<MailTo(%s)>>" % (obfuscated_email_address)
+            'EMAIL': "<<MailTo(%s)>>" % (obfuscated_email_address),
+            'REVISION': str(self.get_real_rev() + 1),
         }
 
         if u.valid and u.name:
diff -r 4186e90ead06 MoinMoin/_tests/test_PageEditor.py
--- a/MoinMoin/_tests/test_PageEditor.py	Sat Oct 04 23:16:54 2008 +0200
+++ b/MoinMoin/_tests/test_PageEditor.py	Tue Oct 21 10:41:13 2008 -0400
@@ -19,6 +19,7 @@
 class TestExpandVars(object):
     """PageEditor: testing page editor"""
     pagename = u'AutoCreatedMoinMoinTemporaryTestPage'
+    revision = 37
 
     _tests = (
         # Variable,             Expanded
@@ -26,10 +27,11 @@
         ("em at PAGE@bedded", "em%sbedded" % pagename),
         ("@NOVAR@", "@NOVAR@"),
         ("case at Page@sensitive", "case at Page@sensitive"),
+        ("@REVISION@", unicode(revision + 1)),
         )
 
     def setup_method(self, method):
-        self.page = PageEditor(self.request, self.pagename)
+        self.page = PageEditor(self.request, self.pagename, rev=self.revision)
 
     def testExpandVariables(self):
         """ PageEditor: expand general variables """


More information about the Moin-user mailing list