Exemplo n.º 1
0
    def publish(self):
        settings = utils.get_global_settings()
        if not settings.autopublish_enabled:
            self.logger.info(self.msg_autopublish_disabled)
            return self.msg_autopublish_disabled

        for brain in self.get_items():
            obj = brain.getObject()
            manager = IPublishStorageManager(obj)
            # XXX: we should delegate default text get to manager (?)
            content = manager.get_text() or utils.get_text(obj)
            for publisher, account_id in manager.get_accounts().items():
                self._publish(content, publisher, account_id=account_id)

        self.logger.info(self.msg_autopublish_done)
        return self.msg_autopublish_done
    def publish(self):
        settings = utils.get_global_settings()
        if not settings.autopublish_enabled:
            self.logger.info(self.msg_autopublish_disabled)
            return self.msg_autopublish_disabled

        for brain in self.get_items():
            obj = brain.getObject()
            manager = IPublishStorageManager(obj)
            # XXX: we should delegate default text get to manager (?)
            content = manager.get_text() or utils.get_text(obj)
            for publisher, account_id in manager.get_accounts().items():
                self._publish(content, publisher, account_id=account_id)

        self.logger.info(self.msg_autopublish_done)
        return self.msg_autopublish_done
Exemplo n.º 3
0
    def test_autopublish(self):
        test_utils.register_fake_publisher()
        utility = component.queryUtility(ISocialPublisherUtility,
                                         name=test_utils.FakePublisher.id)
        # let's create an event
        event = self.create_event()

        view = self.portal.restrictedTraverse('@@social-auto-publish')
        # manager.set_account(test_utils.FakePublisher.id,'simahawk')
        # the event is not auto-publish enabled so we must get no items
        self.assertEqual(len(view.get_items()), 0)
        interface.alsoProvides(event, IAutoPublishable)
        event.reindexObject(idxs=['object_provides'])
        self.assertEqual(len(view.get_items()), 1)
        # but since auto-publish is disabled by default
        # we should get disabled message on publish
        result = view.publish()
        self.assertEqual(result, view.msg_autopublish_disabled)
        # let's enable it
        registry = utils.get_global_settings()
        registry.autopublish_enabled = True
        # and retry
        result = view.publish()
        self.assertEqual(result, view.msg_autopublish_done)
    def test_autopublish(self):
        test_utils.register_fake_publisher()
        utility = component.queryUtility(ISocialPublisherUtility,
                                         name=test_utils.FakePublisher.id)
        # let's create an event
        event = self.create_event()

        view = self.portal.restrictedTraverse('@@social-auto-publish')
        # manager.set_account(test_utils.FakePublisher.id,'simahawk')
        # the event is not auto-publish enabled so we must get no items
        self.assertEqual(len(view.get_items()),0)        
        interface.alsoProvides(event, IAutoPublishable)
        event.reindexObject(idxs=['object_provides'])
        self.assertEqual(len(view.get_items()),1) 
        # but since auto-publish is disabled by default 
        # we should get disabled message on publish
        result = view.publish()
        self.assertEqual(result,view.msg_autopublish_disabled)
        # let's enable it
        registry = utils.get_global_settings()
        registry.autopublish_enabled = True
        # and retry
        result = view.publish()
        self.assertEqual(result,view.msg_autopublish_done)
Exemplo n.º 5
0
 def test_globalsettings(self):
     settings = utils.get_global_settings()
     # autopublish must be disabled by default
     self.assertFalse(settings.autopublish_enabled)
 def test_globalsettings(self):
     settings = utils.get_global_settings()
     # autopublish must be disabled by default
     self.assertFalse(settings.autopublish_enabled)