Description

There is no obvious way for a macro to find out which revision of a page is shown. Some dynamic macros might depend on the page revision. For example, an "upcoming events" macro should show the events for the time of the revision that is being shown when old versions of the page are recalled, not for the current time.

The "obvious" place to look for the revision number inside the macro definition would be macro.request.page.rev, but this seems to be 0 always, even when old revisions are shown. Unless documented otherwise, I'd argue that this is a bug, since macro.request.page.rev reads like "the revision number for the page that is being shown for this request", which is not what the variable contains.

Steps to reproduce

  1. Write a macro that prints macro.request.page.rev.

  2. Use that macro on a wiki page and create several revisions of the wiki page.
  3. Use the "Get info" page to show older versions of the wiki page.

The macro will always print 0 for macro.request.page.rev.

Details

Tried with MoinMoin 1.3.3.

Workaround

Use macro.form.get("rev") and work from there. This works for the current implementation of the actions that show old revisions (show and recall), but I do not think that these actions are guaranteed to use the same arguments in the future, so it is somewhat fragile.

Discussion

I think it would be most consistent if rev were set to a "proper" revision number (rather than 0) even if the current revision is shown (i.e. there is no rev argument to show or recall), but I could live well with 0 standing for "the current revision".

Pages do get a rev keyword to make the page use other revision then the current one, so rev is not always 0. This will probably change in 1.4, don't know if it make sense to try to fix something that may be needed by code that was not written yet, when it is about to change anyway. -- NirSoffer 2005-03-09 00:31:17

There was a change in that direction already some time ago - in 1.4.devel. 1.3 is stable, so we won't change interface.

Plan


CategoryMoinMoinNoBug

MoinMoin: MoinMoinBugs/MacrosDoNotKnowPageRevision (last edited 2007-10-29 19:07:19 by localhost)