Closed iham closed 8 years ago
As I said on the pull request -- it's impossible for plone.supermodel to anticipate how arbitrary vocabulary values should be deserialized. There is already an IFromUnicode
adapter so you can customize how values are interpreted.
situation: set up a plone 5.1a2 site;. create a snapshot in portal_setup. change the day the week should start with in the control panel "Date and Time Settings" create a snapshot in portal_setup again and make a diff between those two.
i then safed this changed settings to my registry.xml
now i set up another plone site and also install my package with this settings stored inside and get an error:
0 -> Monday (Europe), but every other number from 0 (monday) to 6 (sunday) generates the same error.
why is that happening? as far as i can tell, the choice-field validates a given value (the one from the xml file) against a given vocabulary, which is a dict of number(keys) and simpleterms (values). see zope.schema._field.Choice._validate() for that. but the value from the xml is a unicode string, not an int. -> so its not in the vocabulary.
further down the rabbit hole: the value is represented as unicode as it is returned from this method before: see plone.supermodel.utils.elementToValue(). this method converts everything thats not an ICollection or an IDict to unicode. big problem, as the vocabulary of an IChoice can hold ints or strings as keys (maybe even more other types i am not thinking of right now*)
solution(s)
i will implement the third solution, as i am not able (too heavy) to "fix" the Choice field and add value_types to it or reimplement the whole GS-setup infrastructure.