http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11025
Revision: 11025 Author: drtrigon Date: 2013-02-02 12:34:53 +0000 (Sat, 02 Feb 2013) Log Message: ----------- new feature; enable revid in permalink (from rewrite)
Modified Paths: -------------- trunk/pywikipedia/category_redirect.py trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/category_redirect.py =================================================================== --- trunk/pywikipedia/category_redirect.py 2013-02-02 12:34:01 UTC (rev 11024) +++ trunk/pywikipedia/category_redirect.py 2013-02-02 12:34:53 UTC (rev 11025) @@ -296,12 +296,8 @@ rotate_revid = history[-1][0] # append permalink log_text = log_text + ( - "\n\n'''[%s://%s%s/index.php?title=%s&oldid=%s Older logs]'''" - % (self.site.protocol(), - self.site.hostname(), - self.site.scriptpath(), - self.log_page.urlname(), - rotate_revid)) + "\n\n'''[%s Older logs]'''" + % self.log_page.permalink(oldid=rotate_revid)) except IndexError: # don't die if getVersionHistory fails (again) return all_log_text
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2013-02-02 12:34:01 UTC (rev 11024) +++ trunk/pywikipedia/wikipedia.py 2013-02-02 12:34:53 UTC (rev 11025) @@ -1208,13 +1208,18 @@ #pywikibot.output(...) # (or create a own error, e.g. look into interwiki.py)
- def permalink(self): - """Return the permalink URL for current revision of this page.""" - return "%s://%s%s&oldid=%i" % (self.site().protocol(), - self.site().hostname(), - self.site().get_address(self.title()), - self.latestRevision()) + def permalink(self, oldid=None): + """Return the permalink URL of an old revision of this page.
+ @param oldid: The revid of the revision desired. + + """ + return "%s://%s%s&oldid=%i" \ + % (self.site().protocol(), + self.site().hostname(), + self.site().get_address(self.title()), + (oldid if oldid is not None else self.latestRevision())) + def latestRevision(self): """Return the current revision id for this page.""" if not self._permalink: