Skip to content

Commit

Permalink
Make patching of LDAPMultiPlugin explizit. See also #5
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Mar 11, 2015
1 parent 6666fc9 commit ac1ea23
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
7 changes: 6 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ Changelog
6.0 (unreleased)
------------------

- Make patching of LDAPMultiPlugin explizit. Code using those must call
``Products.PlonePAS.ldapmp.patch_ldapmp`` with no parameters in order
to activate the patches.
[jensens]

- Removed (optional) Archetypes Storage (used in past with CMFMember, which
itself was long time ago superseeded by Membrane). Probably dead code. If
theres someone out there needing it in Plone 5 please copy the code from
git/Plone4 in your addon/project.
[jensens]

- Moved ``Extensions/Install.py`` fucntions to setuphandlers, kept BBB import
- Moved ``Extensions/Install.py`` functions to setuphandlers, kept BBB import
for ``activatePluginInterfaces`` since this is imported by ``borg.localrole``.
[jensens]

Expand Down
17 changes: 2 additions & 15 deletions Products/PlonePAS/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
from AccessControl.Permissions import add_user_folders
from Products.CMFCore.utils import ToolInit
from Products.PlonePAS import config
from Products.PlonePAS import pas
from Products.PlonePAS.pas import patch_pas
from Products.PlonePAS.plugins import autogroup
from Products.PlonePAS.plugins import cookie_handler
from Products.PlonePAS.plugins import crumbler
Expand All @@ -19,21 +18,9 @@
from Products.PlonePAS.tools.membership import MembershipTool
from Products.PluggableAuthService import registerMultiPlugin

#################################
# ldapmp monkies if available
# quite dirty, must be moved to PloneLDAP
try:
from Products import LDAPMultiPlugins
from Products import LDAPUserFolder
except ImportError:
pass
else:
from Products.PlonePAS import ldapmp


####################################
# monkey patch pas, the evil happens
pas.patch_all()
patch_pas()

#################################
# new groups tool
Expand Down
20 changes: 15 additions & 5 deletions Products/PlonePAS/ldapmp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from Products.LDAPMultiPlugins.LDAPMultiPlugin import LDAPMultiPlugin
from Products.LDAPMultiPlugins.LDAPPluginBase import LDAPPluginBase
from Products.PlonePAS.patch import call
from Products.PlonePAS.patch import wrap_method
from Products.PlonePAS.plugins.group import PloneGroup
Expand Down Expand Up @@ -45,8 +43,6 @@ def getPropertiesForUser(self, user, request=None):

return properties

wrap_method(LDAPPluginBase, 'getPropertiesForUser', getPropertiesForUser)


def getGroupsForPrincipal(self, user, request=None, attr=None):
""" Fulfill GroupsPlugin requirements, but don't return any groups for
Expand All @@ -59,4 +55,18 @@ def getGroupsForPrincipal(self, user, request=None, attr=None):

return ()

wrap_method(LDAPMultiPlugin, 'getGroupsForPrincipal', getGroupsForPrincipal)

def patch_ldapmp():
from Products.LDAPMultiPlugins.LDAPPluginBase import LDAPPluginBase
wrap_method(
LDAPPluginBase,
'getPropertiesForUser',
getPropertiesForUser
)

from Products.LDAPMultiPlugins.LDAPMultiPlugin import LDAPMultiPlugin
wrap_method(
LDAPMultiPlugin,
'getGroupsForPrincipal',
getGroupsForPrincipal
)
2 changes: 1 addition & 1 deletion Products/PlonePAS/pas.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ def getUserNames(self):
return results


def patch_all():
def patch_pas():
# sort alphabetically by patched/added method name
wrap_method(
PluggableAuthService,
Expand Down
1 change: 1 addition & 0 deletions Products/PlonePAS/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def wrap_method(klass, name, method,


def unwrap_method(klass, name):
# seems to be dead code, nowwhere used nor tested
old_method = getattr(klass, name)
if not isWrapperMethod(old_method):
raise ValueError('Trying to unwrap non-wrapped '
Expand Down

0 comments on commit ac1ea23

Please sign in to comment.