Open frapell opened 5 years ago
@mauritsvanrees What do you think?
The way you put it, such a change would seem to make sense.
But wouldn't this raise a ValueError here? Ah, probably not, because the property would no longer be set, but be filtered out. Seems okay then.
I wonder if we should disallow anything starting with an underscore. That would probably mean changing https://github.com/plone/plone.registry/blob/4d03736d8cf41ffed2323ea6b6d40d2c4b6f7364/plone/registry/fieldfactory.py#L43-L45 into something like this:
context_dict = dict(
[(k, v) for k, v in context.__dict__.items() if k not in ignored
and not k.startswith('_')]
)
I don't know, I don't remember having touched any code in plone.registry
, or having run into problems with it.
Steps to reproduce:
You will see a traceback like this:
If the product was installed and the validator is added afterwards, when you try to reimport the registry.xml the traceback looks like this:
This is what happens in https://github.com/collective/collective.z3cform.datagridfield/issues/14
As I explain in my comment (https://github.com/collective/collective.z3cform.datagridfield/issues/14#issuecomment-454530555), I found that when the persistent field is created, the
__provides__
attribute would be overridden. This only happens when the field has a custom validator defined.In order to fix it, I have added the
__provides__
to the list of ignored attributes by adding to my__init.py__
:I found that the vocabulary attribute is already ignored in https://github.com/plone/plone.registry/blob/4d03736d8cf41ffed2323ea6b6d40d2c4b6f7364/plone/registry/field.py#L280
should I add the
__provides__
here as well as a solution?