Description

self.request.page.get_real_rev() returns always the most current revision if called but not the currently show version. e.g. the max revision is at 3 but the page is show with rev=2 self.request.page.get_real_rev() still retunrs 3.

ps: ThomasWaldmann could reproduce it and told me to report it.

Steps to reproduce

show

self.request.page.get_real_rev() returns 3

Example

see above

Details

MoinMoin Version

moin--main--1.5--patch-79

OS and Version

[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2

Python Version

Python 2.3.5 (#2, May 4 2005, 08:51:39)

Server Setup

Server Details

Workaround

If a page was create without specifying the revision, page.rev is 0, and get_real_rev will return the number of the last revision.

If a page was created with a rev argument, page.rev will return the correct revision number that page display.

Use

revision = page.rev or page.get_real_rev()

page must be the page that actually send the content. In actions, this should not be request.page, as it is set before the action to the last revision of the page.

In theme code, use d['page'] to get the actual page that send the content.

Discussion

Changing this may break other code that except it to return the real number of the last revision of the page and not 0.

One can get the current revision with code like:

revision = page.rev or page.get_real_rev()

But this is bad because it expose the strange implementation of page rev variable. Better add a method hide this:

def revision(self):
    return page.rev or self.get_real_rev()

Renaming get_real_rev to last_revision will make it more clear.

Here is an example of adding revision number to the page information:

    def pageinfo(self, page):
        _ = self.request.getText        
        if not self.shouldShowPageinfo(page):
            return ''

        info = page.lastEditInfo()
        info['revision'] = page.rev or page.get_real_rev()
        if info['editor']:
            info = _("last edited %(time)s by %(editor)s (revision %(revision)s)") % info
        else:
            info = _("last modified %(time)s (revision %(revision)s)") % info
                
        return '<p id="pageinfo" class="info"%(lang)s>%(info)s</p>\n' % {
            'lang': self.ui_lang_attr(),
            'info': info
            }

Plan


CategoryMoinMoinBugFixed

MoinMoin: MoinMoinBugs/page.get_real_revIsBroken (last edited 2008-03-18 19:55:34 by JohannesBerg)