Skip to content

Commit

Permalink
Merge pull request #37 from plone/maurits/uninstall
Browse files Browse the repository at this point in the history
Add uninstall code
  • Loading branch information
mauritsvanrees authored Sep 19, 2019
2 parents 050b647 + 6ddb9a3 commit 460add7
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 4 additions & 0 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions plone/app/ldap/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
/>

<genericsetup:registerProfile
name="uninstall"
title="LDAP support (uninstall)"
directory="profiles/uninstall"
provides="Products.GenericSetup.interfaces.EXTENSION"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
post_handler=".setuphandlers.uninstall"
/>

<genericsetup:importStep name="ldap-settings-import"
title="LDAP Settings Import"
description="Import custom LDAP and AD settings."
Expand Down
10 changes: 10 additions & 0 deletions plone/app/ldap/profiles/uninstall/componentregistry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<componentregistry>
<utilities>
<utility
interface="plone.app.ldap.engine.interfaces.ILDAPConfiguration"
factory="plone.app.ldap.engine.storage.LDAPConfiguration"
remove="true"
/>
</utilities>
</componentregistry>
4 changes: 4 additions & 0 deletions plone/app/ldap/profiles/uninstall/controlpanel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<object name="portal_controlpanel">
<configlet action_id="ldap" appId="Plone" category="Products" remove="true" />
</object>
4 changes: 4 additions & 0 deletions plone/app/ldap/profiles/uninstall/metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<metadata>
<version>1000</version>
</metadata>
18 changes: 18 additions & 0 deletions plone/app/ldap/setuphandlers.py
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 10 additions & 2 deletions plone/app/ldap/tests/test_controlpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand All @@ -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']

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
'plone.memoize',
'Products.CMFCore',
'Products.CMFDefault',
'Products.GenericSetup',
'Products.GenericSetup >= 1.8.2',
'Products.PloneLDAP',
'python-ldap',
'setuptools',
Expand Down

0 comments on commit 460add7

Please sign in to comment.