Revision: 8169 Author: russblau Date: 2010-05-14 18:52:25 +0000 (Fri, 14 May 2010)
Log Message: ----------- API interface for watching pages changed six months ago, but was not announced on its mailing list. <sigh>
Modified Paths: -------------- branches/rewrite/pywikibot/page.py branches/rewrite/pywikibot/site.py
Modified: branches/rewrite/pywikibot/page.py =================================================================== --- branches/rewrite/pywikibot/page.py 2010-05-14 18:40:44 UTC (rev 8168) +++ branches/rewrite/pywikibot/page.py 2010-05-14 18:52:25 UTC (rev 8169) @@ -690,7 +690,8 @@ most wikis strongly encourage its use) @type comment: unicode @param watch: if True, add or if False, remove this Page to/from bot - user's watchlist; if None, leave watchlist status unchanged + user's watchlist; if None (default), follow bot account's default + settings @type watch: bool or None @param minor: if True, mark this edit as minor @type minor: bool @@ -709,26 +710,27 @@ if not comment: comment = config.default_edit_summary if watch is None: - unwatch = False - watch = False + watchval = None + elif watch: + watchval = "watch" else: - unwatch = not watch + watchval = "unwatch" if not force and not self.botMayEdit(): raise pywikibot.PageNotSaved( "Page %s not saved; editing restricted by {{bots}} template" % self.title(asLink=True)) if async: - pywikibot.async_request(self._save, comment, minor, watch, unwatch, + pywikibot.async_request(self._save, comment, minor, watchval, async, callback) else: - self._save(comment, minor, watch, unwatch, async, callback) + self._save(comment, minor, watchval, async, callback)
- def _save(self, comment, minor, watch, unwatch, async, callback): + def _save(self, comment, minor, watchval, async, callback): err = None link = self.title(asLink=True) try: done = self.site().editpage(self, summary=comment, minor=minor, - watch=watch, unwatch=unwatch) + watch=watchval) if not done: pywikibot.warning(u"Page %s not saved" % link) raise pywikibot.PageNotSaved(link)
Modified: branches/rewrite/pywikibot/site.py =================================================================== --- branches/rewrite/pywikibot/site.py 2010-05-14 18:40:44 UTC (rev 8168) +++ branches/rewrite/pywikibot/site.py 2010-05-14 18:52:25 UTC (rev 8169) @@ -2230,7 +2230,7 @@ }
def editpage(self, page, summary, minor=True, notminor=False, - recreate=True, createonly=False, watch=False, unwatch=False): + recreate=True, createonly=False, watch=None): """Submit an edited Page object to be saved to the wiki.
@param page: The Page to be saved; its .text property will be used @@ -2244,9 +2244,12 @@ title has previously been deleted @param createonly: if True, raise an error if this title already exists on the wiki - @param watch: if True, add this Page to bot's watchlist - @param unwatch: if True, remove this Page from bot's watchlist if - possible + @param watch: Specify how the watchlist is affected by this edit, set + to one of "watch", "unwatch", "preferences", "nochange": + * watch: add the page to the watchlist + * unwatch: remove the page from the watchlist + * preferences: use the preference settings (Default) + * nochange: don't change the watchlist @return: True if edit succeeded, False if it failed
""" @@ -2285,10 +2288,12 @@ req['recreate'] = "" if createonly: req['createonly'] = "" - if watch: - req['watch'] = "" - elif unwatch: - req['unwatch'] = "" + if watch in ["watch", "unwatch", "preferences", "nochange"]: + req['watch'] = watch + elif watch: + pywikibot.warning( + u"editpage: Invalid watch value '%(watch)s' ignored." + % locals()) ## FIXME: API gives 'badmd5' error ## md5hash = md5() ## md5hash.update(urllib.quote_plus(text.encode(self.encoding()))) @@ -2643,7 +2648,7 @@ 'badfilename': "Target filename is invalid.", 'filetype-unwanted-type': - "File %(msg)s type is unwatched type.", + "File %(msg)s type is unwanted type.", }
# check for required user right