Bugs item #1981451, was opened at 2008-06-01 22:02
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1981451&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: category
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Mikko Silvonen (silvonen)
Assigned to: Nobody/Anonymous (nobody)
Summary: Fix looping bug in catlib.py, add Finnish messages
Initial Comment:
I added some Finnish messages in my copy of category.py and catlib.py, but stumbled into a bug in catlib.py: the copyAndKeep method uses only the first template listed in cfdTemplates and returns True after the first round of the loop. It looks like an indentation error in the code.
See the attached patch for a fix (plus my Finnish translations of the messages).
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1981451&group_…
Bugs item #1981416, was opened at 2008-06-01 19:49
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1981416&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Sébastien Rombauts (srombauts)
Assigned to: Nobody/Anonymous (nobody)
Summary: Add the get_redirect argument to categories() & templates()
Initial Comment:
There is a need to add the "get_redirect" argument (from the "get()" method) to the "categories()", "templates()" and "templatesWithParams()" methods.
This allow for getting categories and templates links from redirect pages, because sometimes they use some. At least do we use a lot of those "categories in redirect pages" to categories acronyms at work into our intern mediawiki installation
Please see the attached patch that I made from the last available svn revision, which currently is r5491.
It is a "svn diff" as short as possible, only 6 lines modified in "wikipedia.py" : each time the add of the argument to the method ("get_redirect=False") then its use when calling the the get() method (get_redirect=get_redirect)
Please note that :
* I added this "get_redirect" argument defaulted to "False"(ie. "get_redirect=False") because that way I am sure not to break anything elsewhere.
It is up to you whereas to default it to "True" or not.
* I added no comments about this new option, solely to reduce the "diff" file. Please let me know if its up to me to add the comment, then I will submit a new fully commented patch.
Best Regards,
SRombauts
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1981416&group_…
Revision: 5490
Author: nicdumz
Date: 2008-06-01 09:39:27 +0000 (Sun, 01 Jun 2008)
Log Message:
-----------
Fixing the broken login on WM sites.
It fetches Special:Userlogin to get a session cookie, and this cookie is being sent with the login data.
I wanted to wait a few days to know if wpSkipCookieCheck was to be allowed on WM sites, but I'm changing my mind :
Committing this fix, even if it fetches one more page, to make sure that WM bots can run, without having to come to #pywikipediabot to ask for the magic use_api_login; I will revert it if wpSkipCookieCheck gets live.
Modified Paths:
--------------
trunk/pywikipedia/family.py
trunk/pywikipedia/login.py
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/family.py
===================================================================
--- trunk/pywikipedia/family.py 2008-06-01 09:32:11 UTC (rev 5489)
+++ trunk/pywikipedia/family.py 2008-06-01 09:39:27 UTC (rev 5490)
@@ -2979,7 +2979,7 @@
return "%s?useskin=monobook&title=%s:Allmessages&ot=html" % (self.path(code), self.special_namespace_url(code))
def login_address(self, code):
- return '%s?useskin=monobook&title=%s:Userlogin&action=submit' % (self.path(code), self.special_namespace_url(code))
+ return '%s?useskin=monobook&title=%s:Userlogin' % (self.path(code), self.special_namespace_url(code))
def captcha_image_address(self, code, id):
return '%s?useskin=monobook&title=%s:Captcha/image&wpCaptchaId=%s' % (self.path(code), self.special_namespace_url(code), id)
Modified: trunk/pywikipedia/login.py
===================================================================
--- trunk/pywikipedia/login.py 2008-06-01 09:32:11 UTC (rev 5489)
+++ trunk/pywikipedia/login.py 2008-06-01 09:39:27 UTC (rev 5490)
@@ -126,7 +126,8 @@
if captchaId:
predata["wpCaptchaId"] = captchaId
predata["wpCaptchaWord"] = captchaAnswer
- address = self.site.login_address()
+ login_address = self.site.login_address()
+ address = login_address + '&action=submit'
if self.site.hostname() in config.authenticate.keys():
headers = {
@@ -139,23 +140,23 @@
wikipedia.cj.save(wikipedia.COOKIEFILE)
return "Ok"
else:
- response, data = self.site.postForm(address, predata, useCookie=False)
- n = 0
+ #Retrieve a session cookie
+ session = self.site.getUrl(login_address, cookie_only=True)
+
+ response, data = self.site.postForm(address, predata, cookies=session)
Reat=re.compile(': (.*?);')
L = []
for eat in response.msg.getallmatchingheaders('set-cookie'):
m = Reat.search(eat)
if m:
- n += 1
L.append(m.group(1))
got_token = False
- log_data = []
for Ldata in L:
if 'Token=' in Ldata:
got_token = True
-
+
if got_token:
return "\n".join(L)
elif not captchaAnswer:
@@ -168,9 +169,9 @@
url = self.site.protocol() + '://' + self.site.hostname() + self.site.captcha_image_address(id)
answer = wikipedia.ui.askForCaptcha(url)
return self.getCookie(remember = remember, captchaId = id, captchaAnswer = answer)
- else:
- return None
+ return None
+
def storecookiedata(self, data):
"""
Stores cookie data.
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-06-01 09:32:11 UTC (rev 5489)
+++ trunk/pywikipedia/wikipedia.py 2008-06-01 09:39:27 UTC (rev 5490)
@@ -4143,12 +4143,13 @@
l.append('wpEditToken=' + wpEditToken)
return '&'.join(l)
- def postForm(self, address, predata, sysop=False, useCookie=True):
+ def postForm(self, address, predata, sysop=False, cookies = None):
"""Post http form data to the given address at this site.
- address is the absolute path without hostname.
- predata is a dict or any iterable that can be converted to a dict,
+ address - the absolute path without hostname.
+ predata - a dict or any iterable that can be converted to a dict,
containing keys and values for the http form.
+ cookies - the cookies to send with the form. If None, send self.cookies
Return a (response, data) tuple, where response is the HTTP
response object and data is a Unicode string containing the
@@ -4157,14 +4158,18 @@
"""
data = self.urlEncode(predata)
try:
- return self.postData(address, data, sysop=sysop,
- useCookie=useCookie)
+ if cookies:
+ return self.postData(address, data, sysop=sysop,
+ cookies=cookies)
+ else:
+ return self.postData(address, data, sysop=sysop,
+ cookies=self.cookies(sysop = sysop))
except socket.error, e:
raise ServerError(e)
def postData(self, address, data,
contentType='application/x-www-form-urlencoded',
- sysop=False, useCookie=True, compress=True):
+ sysop=False, compress=True, cookies=None):
"""Post encoded data to the given http address at this site.
address is the absolute path without hostname.
@@ -4191,8 +4196,8 @@
conn.putheader('Content-Length', str(len(data)))
conn.putheader('Content-type', contentType)
conn.putheader('User-agent', useragent)
- if useCookie and self.cookies(sysop = sysop):
- conn.putheader('Cookie', self.cookies(sysop = sysop))
+ if cookies:
+ conn.putheader('Cookie', cookies)
if False: #self.persistent_http:
conn.putheader('Connection', 'Keep-Alive')
if compress:
@@ -4209,7 +4214,7 @@
# Blub.
conn.close()
conn.connect()
- return self.postData(address, data, contentType, sysop, useCookie)
+ return self.postData(address, data, contentType, sysop, useCookie, compress, cookie)
data = response.read()
@@ -4227,7 +4232,8 @@
return response, data
- def getUrl(self, path, retry = True, sysop = False, data = None, compress = True, no_hostname = False):
+ def getUrl(self, path, retry = True, sysop = False, data = None,
+ compress = True, no_hostname = False, cookie_only=False):
"""
Low-level routine to get a URL from the wiki.
@@ -4237,6 +4243,7 @@
occurs.
sysop - If True, the sysop account's cookie will be used.
data - An optional dict providing extra post request parameters.
+ cookie_only - Only return the cookie the server sent us back
no_hostname - Open the URL given, don't add the hostname before.
Returns the HTML text of the page converted to unicode.
@@ -4319,6 +4326,8 @@
headers = f.info()
+ if cookie_only:
+ return headers.get('set-cookie', '')
contentType = headers.get('content-type', '')
contentEncoding = headers.get('content-encoding', '')
Bugs item #1981134, was opened at 2008-06-01 08:58
Message generated for change (Comment added) made by silvonen
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1981134&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Mikko Silvonen (silvonen)
Assigned to: Nobody/Anonymous (nobody)
Summary: New languages not sorted correctly
Initial Comment:
Some new languages (myv, ext, hif, gan, kaa, mdf, sah, szl and srn) were added in r5440, but the codes were not added in self.alphabetic_revised and self.alphabetic_lb in the file families/wikipedia_family.py, so these languages are not always sorted correctly.
Another problem: As far as I can see, hif, kaa, sah and szl are sorted incorrectly in self.alphabetic in the file family.py. Shouldn't they be sorted as follows?
fa,
hif (Fiji Hindi),
fo (Føroyskt);
pt (Português),
kaa (Qaraqalpaqsha),
crh (Qırımtatarca);
ru (Русский),
sah (Саха тыла / Sakha tyla),
se (Sámegiella); and
sl (Slovenščina),
szl (Ślůnski),
so (Soomaaliga).
I am attaching a patch for family.py. Sorry, no patch for families/wikipedia_family yet.
----------------------------------------------------------------------
>Comment By: Mikko Silvonen (silvonen)
Date: 2008-06-01 09:30
Message:
Logged In: YES
user_id=127947
Originator: YES
Hmm, I wonder how many errors there are with previously added languages?
At least stq (Seeltersk) is sorted incorrectly in self.alphabetic and
missing from the other tables.
Does anyone have a sorting order test kit?
----------------------------------------------------------------------
Comment By: Mikko Silvonen (silvonen)
Date: 2008-06-01 09:09
Message:
Logged In: YES
user_id=127947
Originator: YES
Also ext is sorted incorrectly in self.alphabetic. I'll upload a corrected
patch.
File Added: family.diff
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1981134&group_…
Bugs item #1981134, was opened at 2008-06-01 08:58
Message generated for change (Comment added) made by silvonen
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1981134&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Mikko Silvonen (silvonen)
Assigned to: Nobody/Anonymous (nobody)
Summary: New languages not sorted correctly
Initial Comment:
Some new languages (myv, ext, hif, gan, kaa, mdf, sah, szl and srn) were added in r5440, but the codes were not added in self.alphabetic_revised and self.alphabetic_lb in the file families/wikipedia_family.py, so these languages are not always sorted correctly.
Another problem: As far as I can see, hif, kaa, sah and szl are sorted incorrectly in self.alphabetic in the file family.py. Shouldn't they be sorted as follows?
fa,
hif (Fiji Hindi),
fo (Føroyskt);
pt (Português),
kaa (Qaraqalpaqsha),
crh (Qırımtatarca);
ru (Русский),
sah (Саха тыла / Sakha tyla),
se (Sámegiella); and
sl (Slovenščina),
szl (Ślůnski),
so (Soomaaliga).
I am attaching a patch for family.py. Sorry, no patch for families/wikipedia_family yet.
----------------------------------------------------------------------
>Comment By: Mikko Silvonen (silvonen)
Date: 2008-06-01 09:09
Message:
Logged In: YES
user_id=127947
Originator: YES
Also ext is sorted incorrectly in self.alphabetic. I'll upload a corrected
patch.
File Added: family.diff
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1981134&group_…
Bugs item #1981134, was opened at 2008-06-01 08:58
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1981134&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Mikko Silvonen (silvonen)
Assigned to: Nobody/Anonymous (nobody)
Summary: New languages not sorted correctly
Initial Comment:
Some new languages (myv, ext, hif, gan, kaa, mdf, sah, szl and srn) were added in r5440, but the codes were not added in self.alphabetic_revised and self.alphabetic_lb in the file families/wikipedia_family.py, so these languages are not always sorted correctly.
Another problem: As far as I can see, hif, kaa, sah and szl are sorted incorrectly in self.alphabetic in the file family.py. Shouldn't they be sorted as follows?
fa,
hif (Fiji Hindi),
fo (Føroyskt);
pt (Português),
kaa (Qaraqalpaqsha),
crh (Qırımtatarca);
ru (Русский),
sah (Саха тыла / Sakha tyla),
se (Sámegiella); and
sl (Slovenščina),
szl (Ślůnski),
so (Soomaaliga).
I am attaching a patch for family.py. Sorry, no patch for families/wikipedia_family yet.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1981134&group_…