def testGetPreviousVersion(self):
        """Test ``utils._getPreviousVersion()``."""
        document = self.portal.folder.document1
        ## At this point, the versioning mechanism does not yet hold
        ## any reference to 'document'. Even this first version is not
        ## registered, because we have only called 'invokeFactory()'
        ## to create dummy items...
        previous = getPreviousVersion(document)
        self.failUnlessEqual(previous, None)

        ## ... We have to register it manually to mimic what normally
        ## happens through the web.
        rtool = getToolByName(self.portal, 'portal_repository')
        rtool.save(document, comment='initial version')

        title = document.Title()
        document.setTitle('New title')
        document.update_version_on_edit()  ## Mimic TTW edition
        previous = getPreviousVersion(document)
        self.failUnlessEqual(document.Title(), 'New title')
        self.failUnlessEqual(previous.Title(), title)
    def testGetPreviousVersion(self):
        """Test ``utils._getPreviousVersion()``."""
        document = self.portal.folder.document1
        ## At this point, the versioning mechanism does not yet hold
        ## any reference to 'document'. Even this first version is not
        ## registered, because we have only called 'invokeFactory()'
        ## to create dummy items...
        previous = getPreviousVersion(document)
        self.failUnlessEqual(previous, None)

        ## ... We have to register it manually to mimic what normally
        ## happens through the web.
        rtool = getToolByName(self.portal, 'portal_repository')
        rtool.save(document, comment='initial version')

        title = document.Title()
        document.setTitle('New title')
        document.update_version_on_edit() ## Mimic TTW edition
        previous = getPreviousVersion(document)
        self.failUnlessEqual(document.Title(), 'New title')
        self.failUnlessEqual(previous.Title(), title)
    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)
Example #4
0
    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)