Last modified: 2014-06-06 10:44:00 UTC
I hope mw.wikibase.getEntity("Q535") and mw.wikibase.getProperty("p20") * Even exactly mw.wikibase.getProperty("p20", "Q535") which return a string or nil, * and where the element code is not necessary inside a page-element, * and where it permits to document the module or the templates elsewhere out of their spaces, and to build genealogies or species classifications. other : Now Lua modules work in fr.wikisource, but mw.wikibase.getEntity() do not works. Thanks in advance. I am Rical in wikis.
Sorry : hopes to document the modules or the templates in any namespaces. My present works is Module:Auteur in test2.wikipedia and fr.wikisource
Sorry, I have problems to understand "I hope mw.wikibase.getEntity("Q535") and mw.wikibase.getProperty("p20")". How can you hope a function? What exactly is the request here? What is the current outcome, and what is the expected outcome?
Rical: The mw.wikibase library is provided by Wikidata. There doesn't seem to be anything here that is specific to Scribunto. Why did you reassign it?
In the module or template Auteur/doc I must show examples, but a module page is not an element, then wikidata give nothing to mw.wikibase.getEntity(), and mw.wikibase.getEntity("Q535") do not works. Also in wikidata:Victor Hugo the country property give 142, but in Lua, I cannot ask mw.wikibase.getEntity("Q142"). Then I hope that mw.wikibase.getEntity("Q535") works for any element. Get a property by Lua is very hard by present Lua, because in many cases the result is a script error. Go to see what I wrote in http://test2.wikipedia.org/wiki/Module:Auteur to read some properties from one element in the function m.wikidata, at least and really many more that : local entity = mw.wikibase.getEntity( ) local dat = entity.claims wd.image = dat.p18[0].mainsnak.datavalue.value wd.country = dat.p27[0].mainsnak.datavalue.value["numeric-id"] Reading entity.claims.p18[0] (and others) does not work if one writes entity.claims["p18"][0] then I can't do a loop from a list of properties to query. Then I hope that mw.wikibase.getProperty("p20") works for any property. or entity.getProperty("p20") which return nil or .value or .value["numeric-id"] When getEntity("Q535") and getProperty("p20") already exist, we must thinks about users that want make généalogies or biologic classifications. They probably will like mw.wikibase.getProperty("p20", "Q535") which return a string or nil, and where the element is optional. Sorry for "Scribunto", I don't known where to include a Lua bug.
From my experience, you get script error if the item doesn't have label in your language and/or the article doesn't exist for that language edition. Therefore it's impossible to generate a red link from current mw.wikibase. It's an error that should be caught by the code.
2 changes and 1 option ? My tests are in 2 pages which use the same module : https://test2.wikipedia.org/wiki/Victor_Hugo which give : entity = Q535 , sitelink = Victor Hugo and https://test2.wikipedia.org/wiki/Module:Auteur which give : getEntity=ERREUR In my mind, there are 2 changes to do : * Never return script error, then return nil if the page/query or the property don't exists. * Return the property if it exists. * Perhaps the script error masks some other usefull return. An option ? * Perhaps, in some cases, a third parameter could ask a type for the returned value, for date format... And a type/format could be returned as a second value.
*** This bug has been marked as a duplicate of bug 47930 ***