Revision: 5254 Author: nicdumz Date: 2008-04-23 08:07:44 +0000 (Wed, 23 Apr 2008)
Log Message: ----------- Page.getRestrictions : Raise NoPage when the page does not exist
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2008-04-22 21:03:00 UTC (rev 5253) +++ trunk/pywikipedia/wikipedia.py 2008-04-23 08:07:44 UTC (rev 5254) @@ -1141,8 +1141,12 @@ """ api_url = '/w/api.php?action=query&prop=info&inprop=protection&format=xml&titles=%s' % self.urlname() text = self.site().getUrl(api_url) - if not 'pageid="' in text: # Avoid errors when you can't reach the API - raise Error("API problem, can't reach the API!") + if 'missing=""' in text: + raise NoPage('Page %s does not exist' % self.aslink()) + elif not 'pageid="' in text: + # I don't know what may happen here. + # We may want to have better error handling + raise Error("BUG> API problem.") match = re.findall(r'<protection>(.*?)</protection>', text) restrictions = { 'edit': None, 'move': None }
pywikipedia-l@lists.wikimedia.org