in the Plone add-on product, I have a control panel page on which some configuration parameters can be set. They are stored in plone.registry. The control panel adapter retrieves the various fields in its __init__ method, requesting an interface, for example:
class MultiLanguageExtraOptionsAdapter(LanguageControlPanelAdapter): implementsOnly(IMultiLanguageExtraOptionsSchema) def __init__(self, context): super(MultiLanguageExtraOptionsAdapter, self).__init__(context) self.registry = getUtility(IRegistry) self.settings = self.registry.forInterface( IMultiLanguageExtraOptionsSchema)
Now I add an extra field to the IMultiLanguageExtraOptionsSchema interface and restart plone. An error appears on the control panel page:
KeyError: 'Interface `plone.app.multilingual.interfaces.IMultiLanguageExtraOptionsSchema` defines a field `blah`, for which there is no record.'
(This is expected for the forInterface method, as described in plone.registry README. No entry).
Of course, if I add this field through GenericSetup (registry.xml), and I reinstall the product / rerun the "Control Panel" step, everything is fine:
<registry> <records interface="plone.app.multilingual.interfaces.IMultiLanguageExtraOptionsSchema"> <value key="blah"></value> <records> <registry>
But I do not want to force users to reinstall the product, simply because there is a new option in the product-specific control panel. So my question is: is there a recommended way to get a new record for a new field in plone.registry?
source share