Uninstalling a hidden add-on

I have a policy package that hides some add-ons; I need to uninstall some of them but seems it's not possible neither manually from ZMI, nor using the standard programmatic approach:

  • portal_quickinstaller.uninstallProducts([addon]) fails with AttributeError
  • portal_setup.runAllImportStepsFromProfile(uninstall_profile) fails with KeyError

this is Plone 4.3.

What is the AttributeError?
What is the KeyError?

For the portal_quickinstaller: if the addon is not in the Contents tab of portal_quickinstaller in the ZMI, then you cannot uninstall it.

For portal_setup: on older Plone 4.3 versions, you might need to add profile- in front of the uninstall_profile id. Or if it is already there in your current code: remove it. The ZMI should give you a list of valid profile ids, in the profile Import tab.

seems I had a different issue: the add-on I was trying to uninstall is a Zope 2 product and I was missing its installation for tests:


    def setUpZope(self, app, configurationContext):
        ...
        z2.installProduct(app, 'Products.Doormat')  # BBB: remove in 3.0 

I added that and my tests are working now: