Page MenuHomePhabricator

When loging in to a site, try the site-configured username if any
Closed, InvalidPublic

Description

Originally from: http://sourceforge.net/p/pywikipediabot/patches/621/
Reported by: gallaecio
Created on: 2013-08-03 20:30:54.056000
Subject: When loging in to a site, try the site-configured username if any
Original description:


Version: core-(2.0)
Severity: normal
See Also:
https://sourceforge.net/p/pywikipediabot/patches/621

Details

Reference
bz54541
Related Changes in Gerrit:

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:09 AM
bzimport set Reference to bz54541.
bzimport added a subscriber: Unknown Object (????).

The patch does not appear to solve anything: site.userinfo holds information about the currently logged-in user.

The is an interesting approach which I am guessing solves part of the 'SUL' problem.

Instead of having to add usernames['wikipedia']['*'] = '..'; usernames['wikisource']['*'] = '..'; to user-config.py etc etc for every family in the matrix of the global account.

If a account is logged into it.wp using an entry in user-config.py, and the bot visits en.wikipedia, the bot *is* logged in, as they have a unified account, and the cookie logs them in, and api.py automatically populates userinfo with the username.

That works wonderfully, and doesnt need this patch.

I am guessing this patch is about when there is a 'problem' with the existing login, which might be because of site.py tripping over itself (the login code is a mess), or maybe the server asking the account to login again.

If the password_file contains simple two-part matching entry for the username in siteinfo, the re-login will be automatic. i.e. (bot_username, bot_password) ; not (family, username, password) or other options.

I would like to hear more about how this patch helps, but it does appear useful in limited but crucial circumstances.

Change 176482 had a related patch set uploaded (by John Vandenberg):
login: Use the site object’s username if defined

https://gerrit.wikimedia.org/r/176482

Patch-For-Review

Change 176482 abandoned by Gallaecio:
login: Use the site object's username if defined

https://gerrit.wikimedia.org/r/176482

What is the current behaviour? What username is used when pywikibot tries to log into a site? Can anyone provide a minimal example script to demonstrate the issue at hand?

Xqt subscribed.

Closed as invalid. See example below

>>> import pywikibot
>>> site = pywikibot.Site()
>>> site
APISite("de", "wikipedia")
>>> site.username()
'Xqtest'
>>> site = pywikibot.Site('meta:meta')
>>> site.username()
'Xqtools'
>>>