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.
The bot creates the pages and gives an error: Creating page [[Szerkesztö:SZDSZ]] via API Sleeping for 6.7 seconds, 2010-08-19 23:04:37 Creating page [[Szerkesztövita:SZDSZ]] via API Note: Your sysop account on wikipedia:hu does not have a bot flag. Its edits wil l be visible in the recent changes. Sleeping for 4.8 seconds, 2010-08-19 23:04:49 Do you want to change the protection level of [[hu:Szerkesztö:SZDSZ]]? ([Y]es, [ N]o, [A]ll) a {u'error': {u'info': u"*Existing titles can't be protected with 'create'*", u'code ': u'create-titleexists'}} Sleeping for 6.9 seconds, 2010-08-19 23:04:57 {u'error': {u'info': u"Existing titles can't be protected with 'create'", u'code ': u'create-titleexists'}} Now comes the funny thing: I run the script again. It saves the page with the same text (of course, this will not appear in page history), and now it protects the pages successfully! Updating page [[Szerkesztö:SZDSZ]] via API Sleeping for 7.9 seconds, 2010-08-19 23:14:28 Updating page [[Szerkesztövita:SZDSZ]] via API Note: Your sysop account on wikipedia:hu does not have a bot flag. Its edits wil l be visible in the recent changes. Sleeping for 8.9 seconds, 2010-08-19 23:14:37 Do you want to change the protection level of [[hu:Szerkesztö:SZDSZ]]? ([Y]es, [ N]o, [A]ll) a Changed protection level of page [[Szerkesztö:SZDSZ]]. Sleeping for 7.1 seconds, 2010-08-19 23:14:49 Changed protection level of page [[Szerkesztövita:SZDSZ]]. How is it possible that the second time the pages could be protected, although they were existing titles, too? I tried to change the order of script lines: first protection, and saving afterwards. This works! But this way the bot creates the pages under my sysop name, because they are already protected.
I just have used the lines: userlap.protect(reason=self.summary) vitalap.protect(reason=self.summary) In wikipedia.py protection stands as follows: def protect(self, editcreate = 'sysop', move = 'sysop', etc. So it has only a common "editcreate" parameter. Please help, what is wrong in my solution, and how is it possible, that first time a page cannot be protected, and the second time it can?
2010/8/19 Bináris wikiposta@gmail.com
I tried to change the order of script lines: first protection, and saving afterwards. This works! But this way the bot creates the pages under my sysop name, because they are already protected.
... and removes the protection, becuse protection was only against
creating, not against editing. I had to protect it again. So not good at all.
I have put a time.sleep(20) between the page creation and the page protection, just in case. Perhaps the script was too fast. But nothing happened, the result is the same error as mentioned above.
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.
2010/8/20 stanlekub stanlekub@free.fr
So, basically, you have two main choices:
- throw away your Page() object between the two operations and create a
new one for protection.
I did this, threw it away with Pythons's del, and now it works correctly! I have to declare thet you are a genius. This was not only a useful answer, but very edifying for the future, thank you very much!
Le 20/08/2010 15:48, Bináris a écrit :
2010/8/20 stanlekub <stanlekub@free.fr mailto:stanlekub@free.fr> So, basically, you have two main choices: * throw away your Page() object between the two operations and create a new one for protection.
I did this, threw it away with Pythons's del, and now it works correctly! I have to declare thet you are a genius. This was not only a useful answer, but very edifying for the future, thank you very much!
Hum, genius is (a little bit) exaggerated, but I'm glad if it helped you.
--stan.
pywikipedia-l@lists.wikimedia.org