Support for more than 10 revisions in mediawiki.

Maximum number of revisions in iter_revisions is now 500, the API's limit
for normal users.

webcontentedit has been updated to use the 'count' option for do_log().
This commit is contained in:
Clément Schreiner 2011-02-16 23:19:50 +01:00
commit 6979604e6f
3 changed files with 9 additions and 7 deletions

View file

@ -120,5 +120,5 @@ class WebContentEdit(ReplApplication):
backend_names = (backend_name,) if backend_name is not None else self.enabled_backends
_id = _id.encode('utf-8')
for backend, revision in self.do('iter_revisions', _id):
for backend, revision in self.do('iter_revisions', _id, max_results=self.options.count):
self.format(revision)

View file

@ -27,7 +27,7 @@ __all__ = ['MediawikiBackend']
class MediawikiBackend(BaseBackend, ICapContent):
NAME = 'mediawiki'
MAINTAINER = 'Clément Schreiner'
MAINTAINER = u'Clément Schreiner'
EMAIL = '0.6'
LICENSE = 'GPLv3'
DESCRIPTION = 'Mediawiki wiki software application'
@ -50,8 +50,8 @@ class MediawikiBackend(BaseBackend, ICapContent):
content.content = data
return content
def iter_revisions(self, _id):
for rev in self.browser.iter_wiki_revisions(_id):
def iter_revisions(self, _id, max_results=10):
for rev in self.browser.iter_wiki_revisions(_id, max_results):
yield rev

View file

@ -138,13 +138,15 @@ class MediawikiBrowser(BaseBrowser):
data['lgtoken'] = result['login']['token']
result2 = self.API_post(data)
def iter_wiki_revisions(self, page):
'''Yield 'Revision' objects for the last 10 Revisions of the specified page.'''
def iter_wiki_revisions(self, page, nb_entries):
'''Yield 'Revision' objects for the last <nb_entries> revisions of the specified page.'''
if not self.is_logged():
self.login()
data = {'action': 'query',
'titles': page,
'prop': 'revisions',
'rvprop': 'ids|timestamp|comment|user|flags',
'rvlimit': '10',
'rvlimit': str(nb_entries),
}
result = self.API_get(data)