[Pywikipedia-l] Strange behavior of wikipedia.py when protecting a page

stanlekub stanlekub at free.fr
Fri Aug 20 12:20:22 UTC 2010


On Thu, Aug 19, 2010 at 11:59:06PM +0200, Bináris wrote:
> The idea is to create a user page and a talk page for a blocked user with a
> template, and immediately after creating to protect them.

I didn't dug a lot into your problem, so maybe I'm totally wrong,
but here's my guess :

You use the ame Page() object for the two operations (creation and
protection) ; the result of Page.exists() being cached (through
Page.get()), the script believe that you're trying to protect a
non-existent page, and so uses the 'create' protection level.
Unfortunatly (for you, but it's logical), the 'create' protection can't
be used with already existing pages.

So, basically, you have two main choices:
* throw away your Page() object between the two operations and create a 
  new one for protection.
* issue a Page.get(force=True) on your object, to force the reload 
  (untested).

--stan.



More information about the Pywikipedia-l mailing list