Seems that Plone 5 transformed the old metaTypeNotToList from a blacklist to a structured whitelist: a displayed_types zope.schema.Tuple with vocabulary.
Having a vocabulary here _seem_ a good idea but if you are developing a plone add-on that:
...you can't do both: seems that the registry.xml GS step is executed when the type isn't registered yet, so you'll get an error:
2015-12-01 09:32:41 ERROR Zope.SiteErrorLog 1448958761.440.340856864267 http://localhost:8080/Plone/portal_quickinstaller/reinstallProducts
Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module <string>, line 6, in reinstallProducts
Module AccessControl.requestmethod, line 70, in _curried
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 786, in reinstallProducts
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 686, in installProducts
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 603, in installProduct
- __traceback_info__: ('....',)
Module Products.GenericSetup.tool, line 374, in runAllImportStepsFromProfile
- __traceback_info__: profile-...:default
Module Products.GenericSetup.tool, line 1268, in _runImportStepsFromContext
Module Products.GenericSetup.tool, line 1113, in _doRunImportStep
- __traceback_info__: plone.app.registry
Module plone.app.registry.exportimport.handler, line 49, in importRegistry
Module plone.app.registry.exportimport.handler, line 92, in importDocument
Module plone.app.registry.exportimport.handler, line 218, in importRecord
Module plone.supermodel.utils, line 122, in elementToValue
Module plone.supermodel.utils, line 134, in elementToValue
Module zope.schema._field, line 373, in fromUnicode
Module zope.schema._bootstrapfields, line 182, in validate
Module zope.schema._field, line 389, in _validate
ConstraintNotSatisfied: MyType
This can probably be fixed by registering two separate profiles or some manual operation, but I think this is a excessive boilerplate (and on Plone 4 and below this was more straightforward).
Had the same problem last week when I wanted to hide the type File in the navigation on a site with custom types installed.
<registry>
<record name="plone.displayed_types" interface="Products.CMFPlone.interfaces.controlpanel.INavigationSchema" field="displayed_types">
<value purge="false">
<element purge="true">File</element>
<!-- this breaks install already if you added custom types manually through the web -->
<!-- TODO: how does removing work? -->
<element>my.type</element>
<!--TODO: seems not to be in plone.app.vocabularies.ReallyUserFriendlyTypes and breaks install -->
</value>
</record>
</registry>
@keul @frisi @jensens is the only reason for the Choice field here to populate the control panel form?
It does work to make plone.app.vocabularies.ReallyUserFriendlyTypes use a subclass of SimpleVocbabulary that is permissive (such that "anything goes" for validation of containment), as follows:
class PermissiveVocabulary(SimpleVocabulary):
def __contains__(self, value):
return True
def getTermByToken(self, token):
"""
this works around z3c.form.widget.SequenceWidget.extract()
pseudo-validation (which is broken for a permissive vocabulary).
"""
try:
v = super(PermissiveVocabulary, self).getTermByToken(token)
except LookupError:
# fallback using dummy term, assumes token==value
return SimpleTerm(token)
return v
If this makes sense -- and I think it does -- I will work on this today and submit a PR today with hopes of getting this into plone.app.vocabularies 4.0.2.
This and a solution for #1794 (not directly related, but could be addressed with a similar approach) would make the GS experience much better.
@jensens I'm willing to throw the same solution as proposed here at that one, if it makes sense.
I still need to investigate what is needed to sufficiently write tests for both cases.
See pull request above, this fixes this problem for me -- I can install a one-off type in plone.displayed_types via something like this.
From what I see here this can be closed right? re-open if not.
@gforcada yes, thank you for closing.
I works for me the first time, but not when I uninstall and install the add-on which sets the displayed_types.
Can anybody confirm this behavior?
Tested on Plone 5.0.7 with plone.app.vocabularies = 4.0.2
The same problem appears under Plone 5.1, I can install the add-on, I can uninstall it, but then I get a trace:
Also, after first install, we have the entry u"ENLSubscriber" in the displayed_types tuple, but if one edit this in the registry UI, it's converted to a normal string. But the error after unstalling/installing stays even then.
2017-04-12 17:03:28 ERROR Zope.SiteErrorLog 1492005808.920.812283216095 http://localhost:8080/Plone/install_products
Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module Products.CMFPlone.controlpanel.browser.quickinstaller, line 693, in __call__
Module Products.CMFPlone.controlpanel.browser.quickinstaller, line 458, in install_product
Module Products.GenericSetup.tool, line 388, in runAllImportStepsFromProfile
- __traceback_info__: profile-Products.EasyNewsletter:default
Module Products.GenericSetup.tool, line 1433, in _runImportStepsFromContext
Module Products.GenericSetup.tool, line 1245, in _doRunImportStep
- __traceback_info__: plone.app.registry
Module plone.app.registry.exportimport.handler, line 70, in importRegistry
Module plone.app.registry.exportimport.handler, line 116, in importDocument
Module plone.app.registry.exportimport.handler, line 272, in importRecord
- __traceback_info__: record name: plone.types_not_searched
Module plone.supermodel.utils, line 122, in elementToValue
Module plone.supermodel.utils, line 134, in elementToValue
Module zope.schema._field, line 322, in fromUnicode
Module zope.schema._bootstrapfields, line 183, in validate
Module zope.schema._field, line 338, in _validate
ConstraintNotSatisfied: (u'ENLSubscriber', '')
@MrTango I think this is another problem and you should open a new issue.
Why do you think that this is some thing else?
It's exactly the same error.
@MrTango this is is a different registry record, AFAICT: your traceback indicates that the record involved is plone.types_not_searched, not plone.displayed_types. Unfortunately, the permissive vocabulary fix I put together in plone.app.vocabularies 4.0.2 is deliberately narrow and specifically applied to just ReallyUserFriendlyTypesVocabulary, which may not be used by all registry records (only one of the five type-related vocabularies is using it).
I really cannot know how your add-on is setting the types_not_searched record, and it is not readily apparent to me what interface (and therefore what vocabulary) this record uses for definition. I suspect that your record is using one of the different vocabulary that could also benefit from the PermissiveVocabulary trick described above. You could find out what vocabulary is in use with a pdb.set_trace()
This deserves its own issue, could you open one and reference this discussion, and at-mention me? I am happy to help you track this down. For now, I am re-closing this.
Most helpful comment
See pull request above, this fixes this problem for me -- I can install a one-off type in plone.displayed_types via something like this.