Пример #1
0
def handle_remove_event(context, event):
    """
    Before a object is remvoed the event handler crates a remove job.
    """
    # the event is notified for every subobject, but we only want to check
    # the top object which the users tries to delete
    if context is not event.object:
        return

    if is_sl_contentish(context):
        # Do not delete sl contentish objects, they are deleted when the
        # associated sl container is published.
        return

    # Find the workflow object by walking up. We may be deleting a file
    # within a file-block within a page, where file and file-block have no
    # workflow and we check the page workflow.
    obj = context
    state = None

    while not IPloneSiteRoot.providedBy(obj):
        state = getMultiAdapter((obj, context.REQUEST),
                                IPublisherContextState)
        if state.has_workflow():
            break
        else:
            obj = aq_parent(aq_inner(obj))

    if not state.has_workflow() or not state.has_publisher_config():
        # plone site reached without finding a workflow, therefore
        # the object was never published.
        return

    context.restrictedTraverse('@@publisher.delete')(no_response=True)
def add_move_job(obj, event):
    """
    This event handles move and rename jobs
    """

    if os.environ.get('disable-publisher-for-testing', None):
        return

    if is_sl_contentish(obj):
        # We are moving a simplelayout block, which is considered part
        # of the content.
        # A move of content should not be published instantly, but when
        # the page is published.
        # Since the simplelayout publisher adapter makes sure that blocks
        # are removed when the content no longer exists on the backend,
        # we can savely skip publishing block movements instantly.
        return

    if obj == event.object:
        # do nohting, if we are in portal_factory or the item is just created
        if not event.oldName:
            return
        url_endswith = event.object.REQUEST.get('ACTUAL_URL') \
            .split('/')[-1:][0]
        # also include manage_pasteObjects for ZMI support
        if url_endswith not in ['folder_rename_form',
                                'folder_paste',
                                'manage_pasteObjects',
                                'object_paste']:
            return
        #set event info on
        move_view = queryMultiAdapter(
            (obj, obj.REQUEST),
            name="publisher.move")
        move_view(event, no_response=True)
Пример #3
0
 def test_file_with_workflow_in_listingblock_is_not_contentish(self):
     wftool = getToolByName(self.portal, 'portal_workflow')
     wftool.setChainForPortalTypes(['File'], 'plone_workflow')
     document = create(Builder('file')
                       .within(create(Builder('listing block')
                                      .within(create(Builder('content page'))))))
     self.assertFalse(is_sl_contentish(document))
 def test_textblock_with_workflow_is_not_contentish(self):
     wftool = getToolByName(self.portal, 'portal_workflow')
     wftool.setChainForPortalTypes(
         ['ftw.simplelayout.TextBlock'], 'plone_workflow')
     block = create(Builder('sl textblock')
                    .within(create(Builder('sl content page'))))
     self.assertFalse(is_sl_contentish(block))
Пример #5
0
 def test_file_in_listingblock_is_contentish(self):
     document = create(Builder('file')
                       .within(create(Builder('listing block')
                                      .within(create(Builder('content page'))))))
     self.assertTrue(is_sl_contentish(document))
Пример #6
0
 def test_listingblock_is_contentish(self):
     block = create(Builder('listing block')
                    .within(create(Builder('content page'))))
     self.assertTrue(is_sl_contentish(block))
Пример #7
0
 def test_content_page_is_not_sl_contentish(self):
     page = create(Builder('content page').titled(u'The Page'))
     self.assertFalse(is_sl_contentish(page))
Пример #8
0
 def test_plone_site_is_not_sl_contentish(self):
     self.assertFalse(is_sl_contentish(self.portal))
 def test_trashed_textblock_is_not_sl_contentish(self):
     block = create(Builder('sl textblock')
                    .within(create(Builder('sl content page'))))
     trasher = Trasher(block)
     trasher.trash()
     self.assertFalse(is_sl_contentish(block))
 def test_textblock_is_contentish(self):
     block = create(Builder('sl textblock')
                    .within(create(Builder('sl content page'))))
     self.assertTrue(is_sl_contentish(block))