diff --git a/CHANGES.rst b/CHANGES.rst
index 5a3e1b8..e0ee22c 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -14,6 +14,11 @@ New features:
Bug fixes:
+- Added uninstall profile.
+ This requires Products.GenericSetup 1.8.2+,
+ (available by default in Plone 4.3.8+ and 5.0.3+).
+ [maurits]
+
- Added dependencies so Plone 5 can start.
Removed the Plone 5 classifiers, because there is a test failure,
and it can't have worked before. [maurits]
diff --git a/buildout.cfg b/buildout.cfg
index f2a4559..a039d3e 100644
--- a/buildout.cfg
+++ b/buildout.cfg
@@ -44,6 +44,10 @@ zc.buildout =
five.formlib = 1.0.4
zope.formlib = 4.3.0
+# Plone 4.2 has Products.GenericSetup 1.7, and we need 1.8.2+ for the post_handler.
+# 1.8.10 seems to work on all tested Plone versions.
+Products.GenericSetup = 1.8.10
+
# Rest. In some cases newer versions would pull in Zope 4.
dataflake.fakeldap = 1.1
Products.LDAPMultiPlugins = 1.14
diff --git a/plone/app/ldap/configure.zcml b/plone/app/ldap/configure.zcml
index 198fe9a..c6e2dfa 100644
--- a/plone/app/ldap/configure.zcml
+++ b/plone/app/ldap/configure.zcml
@@ -25,6 +25,15 @@
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
/>
+
+
+
+
+
+
+
diff --git a/plone/app/ldap/profiles/uninstall/controlpanel.xml b/plone/app/ldap/profiles/uninstall/controlpanel.xml
new file mode 100644
index 0000000..928d542
--- /dev/null
+++ b/plone/app/ldap/profiles/uninstall/controlpanel.xml
@@ -0,0 +1,4 @@
+
+
diff --git a/plone/app/ldap/profiles/uninstall/metadata.xml b/plone/app/ldap/profiles/uninstall/metadata.xml
new file mode 100644
index 0000000..b22370d
--- /dev/null
+++ b/plone/app/ldap/profiles/uninstall/metadata.xml
@@ -0,0 +1,4 @@
+
+
+ 1000
+
diff --git a/plone/app/ldap/setuphandlers.py b/plone/app/ldap/setuphandlers.py
new file mode 100644
index 0000000..af16a41
--- /dev/null
+++ b/plone/app/ldap/setuphandlers.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+from Products.CMFCore.utils import getToolByName
+import logging
+
+
+logger = logging.getLogger(__name__)
+
+
+def uninstall(context):
+ """Uninstall script"""
+ PLUGIN_ID = "ldap-plugin"
+ pas = getToolByName(context, 'acl_users')
+
+ # Remove plugin if it exists.
+ if PLUGIN_ID not in pas.objectIds():
+ return
+ pas._delObject(PLUGIN_ID)
+ logger.info('Removed LDAP plugin %s from acl_users.', PLUGIN_ID)
diff --git a/plone/app/ldap/tests/test_controlpanel.py b/plone/app/ldap/tests/test_controlpanel.py
index d175f50..9b0a6d5 100644
--- a/plone/app/ldap/tests/test_controlpanel.py
+++ b/plone/app/ldap/tests/test_controlpanel.py
@@ -4,8 +4,16 @@
from plone.app.ldap.config import PROJECTNAME
from plone.app.ldap.testing import INTEGRATION_TESTING
+import pkg_resources
import unittest
+qi_dist = pkg_resources.get_distribution("Products.CMFQuickInstallerTool")
+if qi_dist.parsed_version > pkg_resources.parse_version("3.0.9"):
+ # This version uses the uninstall profile.
+ SKIP_UNINSTALL_TEST = False
+else:
+ SKIP_UNINSTALL_TEST = True
+
class ControlPanelTestCase(unittest.TestCase):
@@ -32,8 +40,8 @@ def test_controlpanel_installed(self):
a.getAction(self)['id'] for a in self.controlpanel.listActions()]
self.assertIn('ldap', actions)
- # FIXME: https://github.com/plone/plone.app.ldap/issues/26
- @unittest.expectedFailure
+ @unittest.skipIf(SKIP_UNINSTALL_TEST,
+ "uninstall not supported with this old quick installer")
def test_controlpanel_removed_on_uninstall(self):
qi = self.portal['portal_quickinstaller']
diff --git a/setup.py b/setup.py
index 5c72602..96e9def 100644
--- a/setup.py
+++ b/setup.py
@@ -35,7 +35,7 @@
'plone.memoize',
'Products.CMFCore',
'Products.CMFDefault',
- 'Products.GenericSetup',
+ 'Products.GenericSetup >= 1.8.2',
'Products.PloneLDAP',
'python-ldap',
'setuptools',