Revision: 7511 Author: alexsh Date: 2009-10-19 15:36:45 +0000 (Mon, 19 Oct 2009)
Log Message: ----------- Page().getLatestEditors(): change get data from Page().getVersionHistory()
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2009-10-19 12:44:30 UTC (rev 7510) +++ trunk/pywikipedia/wikipedia.py 2009-10-19 15:36:45 UTC (rev 7511) @@ -3393,21 +3393,17 @@ def getLatestEditors(self, limit = 1): """ Function to get the last editors of a page """ #action=query&prop=revisions&titles=API&rvprop=timestamp|user|comment - params = { - 'action' :'query', - 'prop' :'revisions', - 'rvprop' :['user','timestamp'], - 'rvlimit' :limit, - 'titles' :self.title(), - } - try: - data = query.GetData(params, self.site(), encodeTitle = False)['query']['pages'] - except KeyError: - raise NoPage(u'API Error, nothing found in the APIs') + if hasattr(self, '_versionhistory'): + data = self.getVersionHistory(getAll=True, revCount = limit) + else: + data = self.getVersionHistory(revCount = limit) + + result = [] + for i in data: + result.append({'user':i[2],'timestamp':i[1]}) + + return result
- # We don't know the page's id, if any other better idea please change it - return data.values()[0][u'revisions'] - class ImagePage(Page): """A subclass of Page representing an image descriptor wiki page.