I'm working on a package that includes a control panel created using plone.app.registry. I followed Timo's tutorial but, when trying to add an additional record to it, I'm facing the infamous KeyError: a field for which there is no record.
So I have a couple of questions about best practices:
My first question is: a package must remove it's registry at uninstall time?
I used this in registry.xml of my package:
<registry>
<records interface="collective.nitf.controlpanel.INITFSettings" />
</registry>
and this on metadata.xml:
<metadata>
<version>1</version>
<dependencies>
<dependency>profile-plone.app.registry:default</dependency>
</dependencies>
</metadata>
But adding a delete="true" on the uninstall profile seems not to be working. I tried also by listing all records by name with no luck, unless I run the step manually at ZMI.
So, my second question is: how do I remove control panel records at uninstall time gracefully?
To test if a record is on the registry I do something like this:
def setUp(self):
self.portal = self.layer['portal']
setRoles(self.portal, TEST_USER_ID, ['Manager'])
# Set up the NITF settings registry
self.registry = Registry()
self.registry.registerInterface(INITFSettings)
def test_record_sections(self):
# Test that the sections record is in the control panel
record_sections = self.registry.records[
'collective.nitf.controlpanel.INITFSettings.sections']
self.failUnless('sections' in INITFSettings)
self.assertEquals(record_sections.value, set([]))
A third question could be how to test if a record was removed at unisntall time.
Any other recommendation?