Revision: 8158
Author: shizhao
Date: 2010-05-12 15:29:13 +0000 (Wed, 12 May 2010)
Log Message:
-----------
new add protection().
Return list of dicts of this page protection level.
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2010-05-12 08:50:38 UTC (rev 8157)
+++ trunk/pywikipedia/wikipedia.py 2010-05-12 15:29:13 UTC (rev 8158)
@@ -241,6 +241,7 @@
getReferences : List of pages linking to the page
canBeEdited (*) : True if page is unprotected or user has edit
privileges
+ protection(*) : This page protection level
botMayEdit (*) : True if bot is allowed to edit page
put(newtext) : Saves the page
put_async(newtext) : Queues the page to be saved asynchronously
@@ -2115,6 +2116,25 @@
# page is locked and we don't have a sysop account.
return False
+ def protection(self):
+ """Return list of dicts of this page protection level. like:
+ [{u'expiry': u'2010-05-26T14:41:51Z', u'type':
u'edit', u'level': u'autoconfirmed'}, {u'expiry':
u'2010-05-26T14:41:51Z', u'type': u'move', u'level':
u'sysop'}]
+
+ if the page non protection, return []
+ """
+
+ params = {
+ 'action': 'query',
+ 'prop' : 'info',
+ 'inprop': 'protection',
+ 'titles' : self.title(),
+ }
+
+ datas = query.GetData(params, self.site())
+ data=datas['query']['pages'].values()[0]['protection']
+ return data
+
+
def toggleTalkPage(self):
"""Return the other member of the article-talk page pair for this
Page.
Show replies by date