Closed harej closed 2 years ago
Could it be your login object was still valid in memory? This sometimes happens when working with for example jupyter notebooks. I tried to reproduce but can't. When I don't provide the wikibase credential (API and sparql) I get the following error message:
One code pattern I can recommend is the following
wikibase = "https://{}.wiki.opencura.com/".format(wbstack)
api = "https://{}.wiki.opencura.com/w/api.php".format(wbstack)
sparql = "https://{}.wiki.opencura.com/query/sparql".format(wbstack)
entityUri = wikibase.replace("https:", "http:")+"entity/"
WBUSER = "<Username>"
WBPASS = "<Password>"
login = wdi_login.WDLogin(WBUSER, WBPASS, mediawiki_api_url=api)
localEntityEngine = wdi_core.WDItemEngine.wikibase_item_engine_factory(api,sparql)
item = localEntityEngine(...)```
Hello @harej ,
There is a difference between the URL passed to WDLogin and WDItemEngine. They are not shared.
You need to change your code like this:
item = wdi_core.WDItemEngine(
wd_item_id=wcd_qid,
mediawiki_api_url=mediawiki_api_url,
sparql_endpoint_url=sparql_endpoint_url,
wikibase_url=wiki,
new_item=approve_new_item(pageid),
data=itemdata)
or overloading the wbi_config to change the default URLs:
from wikidataintegrator.wdi_config import config as wdi_config
wdi_config['WIKIBASE_URL'] = wiki
wdi_config['MEDIAWIKI_API_URL'] = mediawiki_api_url
wdi_config['MEDIAWIKI_INDEX_URL'] = mediawiki_index_url
wdi_config['SPARQL_ENDPOINT_URL'] = sparql_endpoint_url
Steps to reproduce:
item.write(login)
What should happen: WikidataIntegrator edits the wiki defined at
mediawiki_api_url
using the supplied OAuth credentialsWhat happens instead: WikidataIntegrator edits Wikidata while logged out.
When a different Wikibase is defined, edits should NOT be made to Wikidata. I expect operating environment to be defined in the WDLogin object and it is baffling when a different operating environment would be used anyway.