def onMemberRegistration(self, member, properties): """Handler called when a new portal member has been registered. It returns the number of mails which have been sent. """ if not self.getProperty('member_registration_notification_enabled'): return 0 if self.ignoreNotification(member): return 0 if properties is None: properties = {} ## FIXME: How could it be? (Damien) current_user = getSecurityManager().getUser() extra_bindings = getBasicBindings(member) extra_bindings.update({ 'current_user': current_user, 'member': member, 'properties': properties, 'event': 'registration' }) return self._handlerHelper(member, 'member_registration', extra_bindings, extra_bindings, extra_bindings)
def onDiscussionItemCreation(self, discussion_item): """Handler called when a discussion item is created. It returns the number of mails which have been sent. """ if not self.getProperty( 'discussion_item_creation_notification_enabled'): return 0 if self.ignoreNotification(discussion_item): return 0 ## We add two bindings to disambiguate the meaning of 'here' ## in the mail template and the rules: 'discussion_item' and ## 'discussed_item'. discussed_item = discussion_item while discussed_item.meta_type == discussion_item.meta_type: discussed_item = discussed_item.aq_inner.aq_parent.aq_parent extra_bindings = getBasicBindings(discussed_item) extra_bindings.update({ 'discussion_item': discussion_item, 'discussed_item': discussed_item }) return self._handlerHelper(discussion_item, 'discussion_item_creation', extra_bindings, extra_bindings, extra_bindings)
def onItemRemoval(self, obj): """Handler called when an item is removed. It returns the number of mails which have been sent. """ if not self.getProperty('item_removal_notification_enabled'): return 0 if self.ignoreNotification(obj): return 0 extra_bindings = getBasicBindings(obj) return self._handlerHelper(obj, 'item_removal', extra_bindings)
def onItemModification(self, obj): """Handler called when an item is modified. It returns the number of mails which have been sent. """ if not self.getProperty('item_modification_notification_enabled'): return 0 if self.ignoreNotification(obj): return 0 extra_bindings = getBasicBindings(obj) changenote = self._getChangeNote(obj) extra_bindings.update({'current': obj, 'previous': getPreviousVersion(obj), 'changenote': changenote }) return self._handlerHelper(obj, 'item_modification', extra_bindings)
def onWorkflowTransition(self, obj, action): """Handler called when a workflow transition is triggered. It returns the number of mails which have been sent. """ if not self.getProperty('wf_transition_notification_enabled'): return 0 if self.ignoreNotification(obj): return 0 wtool = getToolByName(self, 'portal_workflow') comments = wtool.getInfoFor(obj, 'comments') extra_bindings = getBasicBindings(obj) extra_bindings.update({'transition': action, 'comments': comments, 'previous_state': getPreviousWorkflowState(obj)}) return self._handlerHelper(obj, 'wf_transition', extra_bindings)
def onItemModification(self, obj): """Handler called when an item is modified. It returns the number of mails which have been sent. """ if not self.getProperty('item_modification_notification_enabled'): return 0 if self.ignoreNotification(obj): return 0 extra_bindings = getBasicBindings(obj) extra_bindings.update({ 'current': obj, 'previous': getPreviousVersion(obj) }) return self._handlerHelper(obj, 'item_modification', extra_bindings, extra_bindings, extra_bindings)
def onItemCreation(self, obj): """Handler called when an item is created. It returns the number of mails which have been sent. **Warning:** this handler is not called when a discussion item is added. In this case, ``onDiscussionItemCreation()`` is called instead. """ if not self.getProperty('item_creation_notification_enabled'): return 0 if self.ignoreNotification(obj): return 0 extra_bindings = getBasicBindings(obj) return self._handlerHelper(obj, 'item_creation', extra_bindings, extra_bindings, extra_bindings)
def onItemCreation(self, obj): """Handler called when an item is created. It returns the number of mails which have been sent. **Warning:** this handler is not called when a discussion item is added. In this case, ``onDiscussionItemCreation()`` is called instead. """ if not self.getProperty('item_creation_notification_enabled'): return 0 if self.ignoreNotification(obj): return 0 extra_bindings = getBasicBindings(obj) changenote = self._getChangeNote(obj) extra_bindings.update({'changenote': changenote }) return self._handlerHelper(obj, 'item_creation', extra_bindings)
def onWorkflowTransition(self, obj, action): """Handler called when a workflow transition is triggered. It returns the number of mails which have been sent. """ if not self.getProperty('wf_transition_notification_enabled'): return 0 if self.ignoreNotification(obj): return 0 wtool = getToolByName(self, 'portal_workflow') comments = wtool.getInfoFor(obj, 'comments') extra_bindings = getBasicBindings(obj) extra_bindings.update({ 'transition': action, 'comments': comments, 'previous_state': getPreviousWorkflowState(obj) }) current_state_display = extra_bindings['current_state'] previous_state_display = extra_bindings['previous_state'] try: wf_def = wtool.getWorkflowsFor(obj) if len(wf_def) > 0: curr_wf = wf_def[0] wf_states = curr_wf.states current_state_display = wf_states[ extra_bindings['current_state']].title if extra_bindings['previous_state'] <> None: previous_state_display = wf_states[ extra_bindings['previous_state']].title else: previous_state_display = "" except AttributeError: pass extra_bindings.update({ 'current_state_title': current_state_display, 'previous_state_title': previous_state_display, }) return self._handlerHelper(obj, 'wf_transition', extra_bindings, extra_bindings, extra_bindings)
def onWorkflowTransition(self, obj, action): """Handler called when a workflow transition is triggered. It returns the number of mails which have been sent. """ if not self.getProperty('wf_transition_notification_enabled'): return 0 if self.ignoreNotification(obj): return 0 wtool = getToolByName(self, 'portal_workflow') comments = wtool.getInfoFor(obj, 'comments') extra_bindings = getBasicBindings(obj) extra_bindings.update({ 'transition': action, 'comments': comments, 'previous_state': getPreviousWorkflowState(obj) }) return self._handlerHelper(obj, 'wf_transition', extra_bindings)
def onMemberModification(self, member): """Handler called when a member changes his/her properties. It returns the number of mails which have been sent. """ ## FIXME: this should go away when we rely on the appropriate ## event. ## This method can also be called when the member is ## registered. We have to check that. stack = inspect.stack() ## 1st item is ourself ## 2nd item is 'CMFCore.MemberDataTool.notifyMemberModified()' ## 3rd item is 'CMFCore.MemberDataTool.setMemberProperties()' ## 4th item is what we want to check: it is either 'addMember' ## or 'setProperties()' caller = stack[3][3] if caller != 'setProperties': return 0 if not self.getProperty('member_modification_notification_enabled'): return 0 if self.ignoreNotification(member): return 0 ## FIXME: what is the purpose of the following lines? (Damien) memberdata = getToolByName(self, 'portal_memberdata') properties = {} for key, value in memberdata.propertyItems(): properties[key] = value current_user = getSecurityManager().getUser() extra_bindings = getBasicBindings(None) extra_bindings.update({ 'current_user': current_user, 'member': member, 'properties': properties, 'event': 'modification' }) return self._handlerHelper(member, 'member_modification', extra_bindings, extra_bindings, extra_bindings)
def onDiscussionItemCreation(self, discussion_item): """Handler called when a discussion item is created. It returns the number of mails which have been sent. """ if not self.getProperty('discussion_item_creation_notification_enabled'): return 0 if self.ignoreNotification(discussion_item): return 0 ## We add two bindings to disambiguate the meaning of 'here' ## in the mail template and the rules: 'discussion_item' and ## 'discussed_item'. discussed_item = discussion_item while discussed_item.meta_type == discussion_item.meta_type: discussed_item = discussed_item.aq_inner.aq_parent.aq_parent extra_bindings = getBasicBindings(discussed_item) extra_bindings.update({'discussion_item': discussion_item, 'discussed_item': discussed_item}) return self._handlerHelper(discussion_item, 'discussion_item_creation', extra_bindings)
def onMemberModification(self, member): """Handler called when a member changes his/her properties. It returns the number of mails which have been sent. """ ## FIXME: this should go away when we rely on the appropriate ## event. ## This method can also be called when the member is ## registered. We have to check that. stack = inspect.stack() ## 1st item is ourself ## 2nd item is 'CMFCore.MemberDataTool.notifyMemberModified()' ## 3rd item is 'CMFCore.MemberDataTool.setMemberProperties()' ## 4th item is what we want to check: it is either 'addMember' ## or 'setProperties()' caller = stack[3][3] if caller != 'setProperties': return 0 if not self.getProperty('member_modification_notification_enabled'): return 0 if self.ignoreNotification(member): return 0 ## FIXME: what is the purpose of the following lines? (Damien) memberdata = getToolByName(self, 'portal_memberdata') properties = {} for key, value in memberdata.propertyItems(): properties[key] = value current_user = getSecurityManager().getUser() extra_bindings = getBasicBindings(None) extra_bindings.update({'current_user': current_user, 'member': member, 'properties': properties, 'event': 'modification'}) return self._handlerHelper(member, 'member_modification', extra_bindings, extra_bindings, extra_bindings)
def onWorkflowTransition(self, obj, action): """Handler called when a workflow transition is triggered. It returns the number of mails which have been sent. """ if not self.getProperty('wf_transition_notification_enabled'): return 0 if self.ignoreNotification(obj): return 0 wtool = getToolByName(self, 'portal_workflow') comments = wtool.getInfoFor(obj, 'comments') extra_bindings = getBasicBindings(obj) extra_bindings.update({'transition': action, 'comments': comments, 'previous_state': getPreviousWorkflowState(obj)}) current_state_display = extra_bindings['current_state'] previous_state_display = extra_bindings['previous_state'] try: wf_def = wtool.getWorkflowsFor(obj) if len(wf_def) > 0: curr_wf = wf_def[0] wf_states = curr_wf.states current_state_display = wf_states[extra_bindings['current_state']].title if extra_bindings['previous_state'] <> None: previous_state_display = wf_states[extra_bindings['previous_state']].title else: previous_state_display = "" except AttributeError: pass extra_bindings.update({'current_state_title': current_state_display, 'previous_state_title': previous_state_display,}) return self._handlerHelper(obj, 'wf_transition', extra_bindings, extra_bindings, extra_bindings)
def onMemberRegistration(self, member, properties): """Handler called when a new portal member has been registered. It returns the number of mails which have been sent. """ if not self.getProperty('member_registration_notification_enabled'): return 0 if self.ignoreNotification(member): return 0 if properties is None: properties = {} ## FIXME: How could it be? (Damien) current_user = getSecurityManager().getUser() extra_bindings = getBasicBindings(member) extra_bindings.update({'current_user': current_user, 'member': member, 'properties': properties, 'event': 'registration'}) return self._handlerHelper(member, 'member_registration', extra_bindings)