summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Vagelpohl <jens@netz.ooo>2005-09-11 14:12:25 +0000
committerJens Vagelpohl <jens@netz.ooo>2005-09-11 14:12:25 +0000
commit4fe6ec4e2f558568325c871ead178f4ed4912f6a (patch)
treebc4d58ae3559054f9691892b81251a85080f651f
parent5279005808688163f3a3c0acfac0f24bc7e3fc10 (diff)
downloadCMFLDAP-4fe6ec4e2f558568325c871ead178f4ed4912f6a.zip
CMFLDAP-4fe6ec4e2f558568325c871ead178f4ed4912f6a.tar.gz
Checkpoint checkin:
Bugs fixed: * Import changes to account for CMF changes Features removed: * Remove the specialized PloneLDAPMembershipTool. I'm simply unable to support something I don't use myself. Once Plone moves to a PluggableAuthService-based user folder, I will endeavor to support that. Other: * Changed license to ZPL version 2.1 * Switched over to a fully CMFSetup-driven installation process
-rw-r--r--CHANGES.txt19
-rw-r--r--COPYRIGHT.txt9
-rw-r--r--Extensions/Install.py141
-rw-r--r--LDAPMemberDataTool.py8
-rw-r--r--LDAPMembershipTool.py2
-rw-r--r--LICENSE.txt129
-rw-r--r--PloneLDAPMembershipTool.py125
-rw-r--r--VERSION.txt2
-rw-r--r--__init__.py32
-rw-r--r--profiles/default/skins.xml8
-rw-r--r--profiles/default/toolset.xml7
11 files changed, 111 insertions, 371 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index a034cf1..924f1f0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,10 @@
CHANGES.txt for CMFLDAP
- CMFLDAP 2.1
+ After CMFLDAP 2.0
+
+ Bugs fixed:
+
+ * Import changes to account for CMF changes
Features added:
@@ -8,6 +12,19 @@ CHANGES.txt for CMFLDAP
more interoperable with the PortalNotifications package.
Tracker issue 323 from Doug Winter.
+ Features removed:
+
+ * Remove the specialized PloneLDAPMembershipTool. I'm simply
+ unable to support something I don't use myself. Once Plone
+ moves to a PluggableAuthService-based user folder, I will
+ endeavor to support that.
+
+ Other:
+
+ * Changed license to ZPL version 2.1
+
+ * Switched over to a fully CMFSetup-driven installation process
+
CMFLDAP 2.0
diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt
new file mode 100644
index 0000000..0b7dc6c
--- /dev/null
+++ b/COPYRIGHT.txt
@@ -0,0 +1,9 @@
+Copyright (c) 2001-2005 Jens Vagelpohl.
+All Rights Reserved.
+
+This software is subject to the provisions of the Zope Public License,
+Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+FOR A PARTICULAR PURPOSE.
diff --git a/Extensions/Install.py b/Extensions/Install.py
deleted file mode 100644
index a5584a7..0000000
--- a/Extensions/Install.py
+++ /dev/null
@@ -1,141 +0,0 @@
-#
-# Install This script can be run *inside* a normal CMF Site and will
-# make all necessary changes to convert membership to an
-# LDAP-based setup
-#
-
-from Products.CMFLDAP import cmfldap_globals
-from Products.CMFCore.DirectoryView import addDirectoryViews
-from Products.CMFCore.utils import getToolByName
-from Products.CMFLDAP.LDAPMembershipTool import LDAPMembershipTool, \
- manage_addLDAPMembershipTool
-from Products.CMFLDAP.LDAPMemberDataTool import LDAPMemberDataTool, \
- manage_addLDAPMemberDataTool
-
-try:
- # Only expose Plone tools if Plone is installed
- from Products.CMFLDAP.PloneLDAPMembershipTool import PloneLDAPMembershipTool, \
- manage_addPloneLDAPMembershipTool
- PLONE_TOOLS = (
- ('portal_membership', PloneLDAPMembershipTool),
- ('portal_memberdata', LDAPMemberDataTool),
- )
-except ImportError:
- PLONE_TOOLS = ()
-
-#
-# List all specially initialized components
-########################################################
-
-CMF_TOOLS = (
- ('portal_membership', LDAPMembershipTool),
- ('portal_memberdata', LDAPMemberDataTool),
- )
-
-
-#
-# Initialize the log
-#########################################################
-
-log = []
-
-
-#
-# The main conversion method. This is the method name showing in
-# the external method object to be instantiated and run in Zope
-#########################################################
-
-def install(self):
- """ The central conversion method """
- log.append('Starting LDAP Membership conversion\n')
-
- # Find the portal to be modified. It is assumed that the external method
- # is instantiated at the root of the portal.
- portal = self
- if portal.meta_type not in ('CMF Site', 'Plone Site'):
- return 'You are not running this method inside a CMF Site Instance!'
- else:
- log.append('Found CMF Site at %s' % portal.absolute_url())
-
-
- # Instantiate tools that are not in the standard CMF site
- log.append('\n * Instantiating Tools in the portal:')
- if portal.__class__.__name__ == 'PloneSite':
- TOOL_CLASSES = PLONE_TOOLS
- else:
- TOOL_CLASSES = CMF_TOOLS
-
- for tool_tuple in TOOL_CLASSES:
- registerTool(portal, tool_tuple)
-
-
- # Register the skins directories as Filesystem Directory View
- # in the skins tool (portal_skins)
- log.append('\n * Registering skins directories with the Skins Tool:')
- registerSkins(portal)
-
- log.append('\nFinished conversion process!\n\n')
-
- return '\n'.join(log)
-
-
-#
-# Helper methods to register varous components with the CMF machinery
-###############################################################
-
-def registerTool(portal_obj, tool_tuple):
- """ Register tools that do not come with the CMF """
- tool_id = tool_tuple[0]
- tool_obj = tool_tuple[1]()
-
- if hasattr(portal_obj, tool_id):
- old_tool = getattr(portal_obj, tool_id)
- if hasattr(old_tool, '_actions'):
- old_actions = old_tool.listActions()
- else:
- old_actions = None
- portal_obj._delObject(tool_id)
-
- if tool_id == 'portal_membership':
- if tool_obj.meta_type == 'Plone LDAP Membership Tool':
- manage_addPloneLDAPMembershipTool(portal_obj)
- else:
- manage_addLDAPMembershipTool(portal_obj)
- elif tool_id == 'portal_memberdata':
- manage_addLDAPMemberDataTool(portal_obj)
- md = getattr(portal_obj, tool_id)
- md._properties = old_tool._properties
- for property in old_tool.propertyMap():
- setattr(md, property['id'], old_tool.getProperty(property['id']))
- md._members = old_tool._members
-
- log.append(' - Inserted tool %s' % tool_id)
-
-
-def registerSkins(portal_obj):
- """ Register skins as Filesystem Directory Views"""
- skins_tool = getToolByName(portal_obj, 'portal_skins')
- existing_skins = skins_tool.objectIds()
-
- if 'cmfldap' in existing_skins:
- skins_tool._delObject('cmfldap')
-
- addDirectoryViews(skins_tool, 'skins', cmfldap_globals)
- log.append(' - Registered Filesystem Directory Views')
-
- skins = skins_tool.getSkinPaths()
-
- for skin_name, skin_path in skins:
- path_elems = map(lambda x: x.strip(), skin_path.split(','))
-
- if 'cmfldap' not in path_elems:
- for i in range(len(path_elems)):
- if path_elems[i] == 'custom':
- path_elems.insert(i+1, 'cmfldap')
- break
-
- new_path = ', '.join(path_elems)
- skins_tool.addSkinSelection(skin_name, new_path)
- log.append(' - Adjusted skin path for skin "%s"' % skin_name)
-
-
diff --git a/LDAPMemberDataTool.py b/LDAPMemberDataTool.py
index 7072500..07fdd49 100644
--- a/LDAPMemberDataTool.py
+++ b/LDAPMemberDataTool.py
@@ -10,11 +10,13 @@ __version__='$Revision$'[11:-2]
from Products.CMFCore.utils import getToolByName
-from Products.CMFCore.CMFCorePermissions import View
-from Globals import InitializeClass, DTMLFile
+from Products.CMFCore.permissions import View
+from Globals import InitializeClass
+from Globals import DTMLFile
from Acquisition import aq_base
from AccessControl import ClassSecurityInfo
-from Products.CMFCore.MemberDataTool import MemberDataTool, MemberData
+from Products.CMFCore.MemberDataTool import MemberDataTool
+from Products.CMFCore.MemberDataTool import MemberData
_marker = []
diff --git a/LDAPMembershipTool.py b/LDAPMembershipTool.py
index ded6a9c..26e4300 100644
--- a/LDAPMembershipTool.py
+++ b/LDAPMembershipTool.py
@@ -13,7 +13,7 @@ from zLOG import LOG, ERROR, INFO, PROBLEM, DEBUG
import string
import DateTime
from AccessControl import ClassSecurityInfo
-from Products.CMFCore.CMFCorePermissions import View
+from Products.CMFCore.permissions import View
from Globals import InitializeClass
from Products.CMFDefault.MembershipTool import MembershipTool
diff --git a/LICENSE.txt b/LICENSE.txt
index 644f605..89be00b 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,77 +1,54 @@
-##############################################################################
-#
-# License
-# -------
-#
-# Copyright (c) Jens Vagelpohl. All right reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# 1. Redistributions in source code must retain the above copyright
-# notice, this list of conditions, and the following disclaimer.
-#
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions, and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-#
-# 3. Jens Vagelpohl requests that attribution be given to Zope
-# in any manner possible. A significant investment has been put
-# into Zope, and this effort will continue if the Zope community
-# continues to grow. This is one way to assure that growth.
-#
-# 4. All advertising materials and documentation mentioning
-# features derived from or use of this software must display
-# the following acknowledgement:
-#
-# "This product includes software developed by Jens Vagelpohl
-# for use in the Z Object Publishing Environment
-# (http://www.zope.org/)."
-#
-# In the event that the product being advertised includes an
-# intact CMFLDAP distribution (with copyright and license
-# included) then this clause is waived
-#
-# 5. Names associated with Jens Vagelpohl must not be used to
-# endorse or promote products derived from this software without
-# prior written permission from Jens Vagelpohl.
-#
-# 6. Modified redistributions of any form whatsoever must retain
-# the following acknowledgment:
-#
-# "This product includes software developed by Jens Vagelpohl
-# for use in the Z Object Publishing Environment
-# (http://www.zope.org/)."
-#
-# Intact (re-)distributions of any official CMFLDAP
-# release do not require an external acknowledgement.
-#
-# 7. Modifications are encouraged but must be packaged separately as
-# patches to official software releases. Distributions that do not
-# clearly separate the patches from the original work must be clearly
-# labeled as unofficial distributions.
-#
-# 8. In the interest of improving this product the author requests that
-# changes be made available to him. This is not mandatory but part
-# of good open source development etiquette.
-#
-#
-# Disclaimer
-#
-# THIS SOFTWARE IS PROVIDED BY JENS VAGELPOHL ``AS IS'' AND ANY
-# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JENS VAGELPOHL OR HIS
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-##############################################################################
+Zope Public License (ZPL) Version 2.1
+
+A copyright notice accompanies this license document that
+identifies the copyright holders.
+
+This license has been certified as open source. It has also
+been designated as GPL compatible by the Free Software
+Foundation (FSF).
+
+Redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the
+following conditions are met:
+
+1. Redistributions in source code must retain the
+ accompanying copyright notice, this list of conditions,
+ and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the accompanying
+ copyright notice, this list of conditions, and the
+ following disclaimer in the documentation and/or other
+ materials provided with the distribution.
+
+3. Names of the copyright holders must not be used to
+ endorse or promote products derived from this software
+ without prior written permission from the copyright
+ holders.
+
+4. The right to distribute this software or to use it for
+ any purpose does not give you the right to use
+ Servicemarks (sm) or Trademarks (tm) of the copyright
+ holders. Use of them is covered by separate agreement
+ with the copyright holders.
+
+5. If any files are modified, you must cause the modified
+ files to carry prominent notices stating that you changed
+ the files and the date of any change.
+
+Disclaimer
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS''
+ AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
+ NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ NO EVENT SHALL THE COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
diff --git a/PloneLDAPMembershipTool.py b/PloneLDAPMembershipTool.py
deleted file mode 100644
index 2a558a4..0000000
--- a/PloneLDAPMembershipTool.py
+++ /dev/null
@@ -1,125 +0,0 @@
-#####################################################################
-#
-# PloneLDAPMembershipTool LDAP-enabled Plone Membership Tool
-#
-# This software is governed by a license. See
-# LICENSE.txt for the terms of this license.
-#
-#####################################################################
-__version__='$Revision$'[11:-2]
-
-from AccessControl import ClassSecurityInfo
-from Products.CMFCore.CMFCorePermissions import View
-from Products.CMFCore.utils import getToolByName
-from Globals import InitializeClass
-from Products.CMFPlone.MembershipTool import MembershipTool as PloneMembership
-from LDAPMembershipTool import LDAPMembershipTool as LDAPMembership
-
-
-class PloneLDAPMembershipTool(LDAPMembership, PloneMembership):
- """ LDAP-enabled Plone Membership Tool """
- security = ClassSecurityInfo()
- meta_type = 'Plone LDAP Membership Tool'
- title = 'Plone LDAP Membership Tool'
-
- security.declareProtected(View, 'searchForMembers')
- def searchForMembers(self, REQUEST=None, **kw):
- """ """
- if REQUEST:
- dict = REQUEST
- else:
- dict = kw
-
- name = dict.get('name', '').strip().lower()
- email = dict.get('email', '').strip().lower()
- roles = dict.get('roles', [])
- last_login_time = dict.get('last_login_time', None)
- is_manager = self.checkPermission('Manage portal', self)
- md = self.portal_memberdata
- res = []
- matches = []
- acl = self.acl_users
- known_attrs = acl.getSchemaConfig().keys()
- login_attr = acl.getProperty('_login_attr')
- memberdata_tool = getToolByName(self, 'portal_memberdata')
- known_members = memberdata_tool._members.keys()
-
- if roles and not name and not email and not last_login_time:
- # Special treatment, this is a lookup by role only
- for role in roles:
- group_data = acl.getGroupDetails(role)
- group_members = group_data[1][1]
-
- for gm in group_members:
- matches.extend( acl.findUser( search_param='dn'
- , search_term=gm
- ) )
-
- if name:
- matches.extend(acl.findUser(login_attr, name))
-
- if email:
- if name:
- # Got name matches, have to weed out stuff
- new_matches = []
-
- for rec in matches:
- if rec.get('mail', '').find(email) != -1:
- new_matches.append(rec)
-
- matches = new_matches
- else:
- matches.extend(acl.findUser('mail', email))
-
- for match in matches:
- member_id = match.get(login_attr)
-
- if member_id in known_members:
- res.append(self.getMemberById(member_id))
-
- if last_login_time:
- new_res = []
-
- for member in res:
- if member.getProperty('last_login_time') > last_login_time:
- new_res.append(member)
-
- res = new_res
-
- if roles:
- new_res = []
-
- for member in res:
- member_roles = member.getRoles()
-
- for r in roles:
- if r in member_roles:
- new_res.append(member)
- break
-
- res = new_res
-
- if not is_manager:
- new_res = []
-
- for member in res:
- if member.getProperty('listed'):
- new_res.append(member)
-
- res = new_res
-
-
- return res
-
-
-InitializeClass(PloneLDAPMembershipTool)
-
-
-def manage_addPloneLDAPMembershipTool(self, REQUEST=None):
- """ Add an LDAP-based Plone Membership Tool """
- tool_obj = PloneLDAPMembershipTool()
- self._setObject(tool_obj.getId(), tool_obj)
-
- if REQUEST is not None:
- return self.manage_main(self, REQUEST)
-
diff --git a/VERSION.txt b/VERSION.txt
index cd5ac03..ae49f38 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -1 +1 @@
-2.0
+2.0+
diff --git a/__init__.py b/__init__.py
index 720e4b9..a85c4b0 100644
--- a/__init__.py
+++ b/__init__.py
@@ -10,36 +10,22 @@
__doc__ = """ CMFLDAP initialization module """
__version__ = '$Revision$'[11:-2]
-from Products.CMFCore import utils, CMFCorePermissions
from Products.CMFCore.DirectoryView import registerDirectory
-import LDAPMemberDataTool
-import LDAPMembershipTool
-
-try:
- # Do we have Plone? If yes, make the Plone tool available
- import PloneLDAPMembershipTool
- tools = ( PloneLDAPMembershipTool.PloneLDAPMembershipTool
- , LDAPMembershipTool.LDAPMembershipTool
- , LDAPMemberDataTool.LDAPMemberDataTool
- )
-except ImportError:
- tools = ( LDAPMembershipTool.LDAPMembershipTool
- , LDAPMemberDataTool.LDAPMemberDataTool
- )
-
-cmfldap_globals = globals()
+from Products.CMFSetup import EXTENSION
+from Products.CMFSetup import profile_registry
# Make the skins available as DirectoryViews
registerDirectory('skins', globals())
-registerDirectory('skins/cmfldap', globals())
def initialize(context):
""" Initializing the CMF LDAP Componentry """
- utils.ToolInit( 'CMF LDAP Tools'
- , tools=tools
- , product_name='CMFLDAP'
- , icon='tool.gif'
- ).initialize(context)
+ profile_registry.registerProfile( 'default'
+ , 'CMFLDAP'
+ , 'Adds LDAP support to the CMF.'
+ , 'profiles/default'
+ , 'CMFLDAP'
+ , EXTENSION
+ )
diff --git a/profiles/default/skins.xml b/profiles/default/skins.xml
new file mode 100644
index 0000000..b6a0131
--- /dev/null
+++ b/profiles/default/skins.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<skins-tool>
+ <skin-directory id="cmfldap"
+ directory="CMFLDAP/skins/cmfldap"/>
+ <skin-path id="*">
+ <layer name="cmfldap" insert-after="custom"/>
+ </skin-path>
+</skins-tool>
diff --git a/profiles/default/toolset.xml b/profiles/default/toolset.xml
new file mode 100644
index 0000000..5d09095
--- /dev/null
+++ b/profiles/default/toolset.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<tool-setup>
+ <required tool_id="portal_memberdata"
+ class="Products.CMFLDAP.LDAPMemberDataTool.LDAPMemberDataTool"/>
+ <required tool_id="portal_membership"
+ class="Products.CMFLDAP.LDAPMembershipTool.LDAPMembershipTool"/>
+</tool-setup>