Open iham opened 8 years ago
@iham Thanks for the report. I'm not sure that there is anything this project can do to fix the issue: your suggested solutions reference Products.CMFPlone
and plone.app.vocabularies
. Maybe plone.supermodel
would be the right place to tackle it?
@tseaver i tried it there, but it seems the wrong way, as there is no way to decide if a string only containing numbers should be a string or number ...
as far as i can see, i stirred up a small hornets' nest: https://github.com/plone/plone.supermodel/pull/17#event-825410280
@iham plone/plone.supermodel#17 is merged. Did this fix your problem, so this issue here in can be closed?
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 does that happen? the choice field (zope.schema) validates a given value (the one from the xml file -> u'0') against its vocabulary, using by_value, which is - in case of plone.app.vocabularies.datetimerelated.WeekdaysFactory - a dict of number (keys) and simpleterm (value) - pairs. but the value from the xml is a unicode string, not an int. -> so its not a key in the vocabulary. see zope.schema._field.Choice._validate() for that.
further down the rabbit hole... most SimpleTerms in plone.app.vocabularies are instantiated by a value (string) and a title (term); only the Month and Weekday Vocabularies are build different. the come with a value, token and title. value is an index, token a string representation of that index and the title (term). this is, at least, inconsistent.
solutions
i will implement the first solution, as i am not able (too heavy) to extend the Choice field or reimplement the whole GS-setup infrastructure.
take a look at: https://github.com/plone/Products.CMFPlone/issues/1794 and https://github.com/plone/plone.app.vocabularies/issues/41
sadly they are cross depending ...