Last modified: 2013-09-04 11:22:39 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 T51265, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 49265 - Spec out registry/factory for formatters and parsers in the backend
Spec out registry/factory for formatters and parsers in the backend
Status: VERIFIED FIXED
Product: MediaWiki extensions
Classification: Unclassified
WikidataRepo (Other open bugs)
unspecified
All All
: Highest normal (vote)
: ---
Assigned To: Wikidata bugs
:
: 48398 (view as bug list)
Depends on:
Blocks: 48937 49186 50277 51113 53745
  Show dependency treegraph
 
Reported: 2013-06-06 17:03 UTC by Daniel Kinzler
Modified: 2013-09-04 11:22 UTC (History)
5 users (show)

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


Attachments

Description Daniel Kinzler 2013-06-06 17:03:54 UTC
Several components of the backend need to format snak values in some way; Similarly, several components have a need to parse snak values. We need a specification of how code can get access to the formatter/parser it needs.

The following things should be considered:

* formatters and parsers can be specific to a property (data) type, or generic for a given DataValue type.
* formatters are specific for a given output type (e.g. wikitext, html, etc).
* formatters and parsers can depend on the user's locale.

Experience with formatters and parsers in the front end's JS code should also be discussed and considered.
Comment 1 Daniel Kinzler 2013-06-07 12:46:06 UTC
*** Bug 48398 has been marked as a duplicate of this bug. ***
Comment 2 Andre Klapper 2013-06-14 20:30:24 UTC
If bug 48937 is really highest priority (set by Denny) and really depends on this bug 49265, then this bug should also have highest priority.
Comment 3 Andre Klapper 2013-06-26 11:20:58 UTC
Is anybody working on / assigned to this?
If bug 48937 is really highest priority (set by Denny) and really depends on
this bug 49265, then this bug should also have highest priority.
Comment 4 denny vrandecic 2013-07-05 14:25:33 UTC
Results from the specification:
* Information about which formatter to use for which value will be in the FormatterFactory
* Parsers are dealt with like Formatters
* Validators are tied to the DataType
* Instead of a BadValue, we have an UndeserializableValue (Naming by Committee) and it only refers to UndeserializableValues, not to Type Mismatches (those will be handled differently, no agreement has been reach as to exactly how)
* a "BadSnak" throws an exception for now and can not be handled as a datastructure around (an UndeserialiazableValue is not a BadSnak in this sense)
* Formatters are to follow the pattern used in Ask, i.e. Options are given to the constructor, it dispatches to different formatters ber format, etc.
* FormatterFactory is injected wherever needed

Also on Wiki here, where it can be changed:
http://meta.wikimedia.org/wiki/Wikidata/Development/Data_values
Comment 5 Daniel Kinzler 2013-07-06 13:36:00 UTC
I'd like to add that I think it would be useful to have one FormatterFactory per desired output type, i.e. one for HTML, one for plain text, etc.
Comment 6 abraham.taherivand 2013-07-17 14:26:43 UTC
Verified in Wikidata demo time July 17th
Comment 7 Daniel A. R. Werner 2013-07-22 09:02:55 UTC
"formatters and parsers can be specific to a property (data) type [...]" is not yet possible in the backend, is it? We should either reopen this or create a new bug for it.
Comment 8 Daniel Kinzler 2013-07-22 09:36:18 UTC
@Danwe: this bug only calls for the specification, which is completed with comment #4. Please open a new ticket for the implementation.

Currently, we can either use a ValueFormatterFactory, selecting formatters based on the DateValue type, or we use the list of ValueFormatters in the DataValue object (no idea why there is a list there...)
Comment 9 Daniel A. R. Werner 2013-07-22 10:29:00 UTC
Right, missed the fact that this was about specs only. Opened bug 51799.

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


Navigation
Links