Last modified: 2014-09-30 22:00:13 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T73451, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 71451 - Site cache does not distinguish between classes
Site cache does not distinguish between classes
Status: RESOLVED FIXED
Product: Pywikibot
Classification: Unclassified
General (Other open bugs)
core-(2.0)
All All
: Unprioritized major
: ---
Assigned To: Pywikipedia bugs
:
Depends on:
Blocks: 71398
  Show dependency treegraph
 
Reported: 2014-09-29 23:43 UTC by John Mark Vandenberg
Modified: 2014-09-30 22:00 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description John Mark Vandenberg 2014-09-29 23:43:22 UTC
pywikibot has a cache of Site objects in the method pywikibot.Site.  It uses a key of (family_name, site_code, username).  If the site is a data repository, and first access of the site is via APISite.data_repository(), a DataSite object will be cached, and subsequent requests for an APISite will return a DataSite instead of an APISite.

DataSite is an APISite, but it has many methods marked as NotImplemented.

Steps to reproduce:
1. Set the user-config.py default site to ar.wikipedia
2. Instantiate a Wikidata client site object for ar.wikipedia
3. Request the Wikidata repo object
4. Instantiate a Wikidata repo site object for wikidata.wikidata

Expected results:
The object returned from step 4 will be an APISite

Actual results:
The object returned from step 4 will be a DataSite

$ python pwb.py shell
Welcome to the Pywikibot interactive shell!
>>> import pywikibot
>>> s = pywikibot.Site('ar', 'wikipedia')
>>> ds = s.data_repository()
>>> ds
DataSite("wikidata", "wikidata")
>>> s2 = pywikibot.Site('wikidata', 'wikidata')
>>> s2
DataSite("wikidata", "wikidata")
Comment 1 John Mark Vandenberg 2014-09-29 23:48:31 UTC
The cache key has been this way since the beginning of pwb20

http://git.wikimedia.org/blobdiff/pywikibot%2Fcore.git/c636fd0db2b41a618bcbcffc02c126dd96cc0d64/pywikibot%2F__init__.py

It only became a problem since the DataSite class was added in 2012

http://git.wikimedia.org/commit/pywikibot%2Fcore.git/aa0ebedcd6a9b3e13af7f40cce7a59925523de5b
Comment 2 John Mark Vandenberg 2014-09-30 00:08:59 UTC
fwiw, this bug was exposed by running more tests on different default site configurations.

https://travis-ci.org/wikimedia/pywikibot-core/jobs/36525125
Comment 3 Gerrit Notification Bot 2014-09-30 00:41:45 UTC
Change 163784 had a related patch set uploaded by John Vandenberg:
Use Site interface in cache key

https://gerrit.wikimedia.org/r/163784
Comment 4 Gerrit Notification Bot 2014-09-30 21:57:31 UTC
Change 163784 merged by jenkins-bot:
Use Site interface in cache key

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

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links