Search code examples
plonegenericsetupplone-5.x

Remove browser layer on Plone 5


In previous versions of Plone, QuickInstaller took care of automagically removing some stuff on uninstall time; that was the case of browser layers and resource registry resources. Now in Plone 5 is a best practice to include a GenericSetup profile to explicitly uninstall those thins.

I folowed up Keul's blog post on uninstalls and added a browserlayer.xml file to my package uninstall profile as follows:

<?xml version="1.0"?>
<layers>
  <layer name="collective.fingerpointing" remove="true" />
</layers>

but my package is not removing it.

any hints?

code is in: https://github.com/collective/collective.fingerpointing/pull/6

test results are in: https://travis-ci.org/collective/collective.fingerpointing/jobs/110195902

I'm just one test away of accomplish compatibility of my add-on!


Solution

  • The problem was in the test: I was testing against the name of the interface and another package (in my case, plone.app.event) had a browser layer with the same name (IBrowserLayer):

    (Pdb) registered_layers()[4]
    <InterfaceClass plone.app.event.interfaces.IBrowserLayer>
    

    I was using this:

    def test_addon_layer_removed(self):
        from plone.browserlayer.utils import registered_layers
        layers = [l.getName() for l in registered_layers()]
        self.assertNotIn('IBrowserLayer', layers)
    

    I change it to the following:

    def test_addon_layer_removed(self):
        from collective.fingerpointing.interfaces import IBrowserLayer
        from plone.browserlayer.utils import registered_layers
        self.assertNotIn(IBrowserLayer, registered_layers())
    

    That's why is important to have the right tests in place.