Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add uninstall code #37

Merged
merged 4 commits into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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