## FIXME: PAS does fire events, we should use them to replace these ## monkey-patches: see "PluggableAuthService/interfaces/events.py". ######### CMFCore.RegistrationTool patch ######################## def afterAdd(self, member, id, password, properties): """Call the original method and also CMFNotification handler.""" self._cmf_notification_orig_afterAdd(member, id, password, properties) ntool = getToolByName(self, ID, None) if ntool is not None: ntool.onMemberRegistration(member, properties) from Products.CMFCore.RegistrationTool import RegistrationTool RegistrationTool._cmf_notification_orig_afterAdd = RegistrationTool.afterAdd RegistrationTool.afterAdd = afterAdd LOG.info('Monkey-patched CMFCore.RegistrationTool') ######### End of CMFCore.RegistrationTool patch ################# ######### CMFCore.MemberDataTool patch ########################## def notifyMemberModified(self): """Call the original method and also CMFNotification handler.""" self._cmf_notification_orig_notifyModified() ntool = getToolByName(self, ID, None) if ntool is not None: membership = getToolByName(self, 'portal_membership') member = membership.getMemberById(self.getId()) ntool.onMemberModification(member) from Products.CMFCore.MemberDataTool import MemberData MemberData._cmf_notification_orig_notifyModified = MemberData.notifyModified
self._orig_notifyModified() ntool = getToolByName(self, ID, None) if ntool is not None: if self.meta_type == 'Discussion Item': ## When a discussion item is added, it is reindexed and, ## therefore, notifyModified() is called, leading ## there. But we want to call a specific handler for this ## event. ntool.onDiscussionItemCreation(self) else: ntool.onItemModification(self) from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl DefaultDublinCoreImpl._orig_notifyModified = DefaultDublinCoreImpl.notifyModified DefaultDublinCoreImpl.notifyModified = notifyModified LOG.info('Monkey-patched CMFDefault') ######### End of CMFDefault.DublinCore patch #################### ######### DCWorkflow patch ###################################### def notifySuccess(self, ob, action, result): ''' Notifies this workflow that an action has taken place. ''' self._orig_notifySuccess(ob, action, result) ntool = getToolByName(self, ID, None) if ntool is not None: ntool.onWorkflowTransition(self, ob, action, result) pass
## monkey-patches: see "PluggableAuthService/interfaces/events.py". ######### CMFCore.RegistrationTool patch ######################## def afterAdd(self, member, id, password, properties): """Call the original method and also CMFNotification handler.""" self._cmf_notification_orig_afterAdd(member, id, password, properties) ntool = getToolByName(self, ID, None) if ntool is not None: ntool.onMemberRegistration(member, properties) from Products.CMFCore.RegistrationTool import RegistrationTool RegistrationTool._cmf_notification_orig_afterAdd = RegistrationTool.afterAdd RegistrationTool.afterAdd = afterAdd LOG.info('Monkey-patched CMFCore.RegistrationTool') ######### End of CMFCore.RegistrationTool patch ################# ######### CMFCore.MemberDataTool patch ########################## def notifyMemberModified(self): """Call the original method and also CMFNotification handler.""" self._cmf_notification_orig_notifyModified() ntool = getToolByName(self, ID, None) if ntool is not None: membership = getToolByName(self, 'portal_membership') member = membership.getMemberById(self.getId()) ntool.onMemberModification(member)