コード例 #1
0
ファイル: feeds.py プロジェクト: appdotnet/pourover
    def format_entry_for_adn(self, entry, for_publish=False):
        posts = []
        if (not self.channel_id or (self.channel_id and self.publish_to_stream)):
            if for_publish and not entry.published_post or not for_publish:
                post = yield format_for_adn(self, entry)
                posts += [(post, 'post')]

        if self.channel_id and not entry.published_channel:
            if for_publish and not entry.published_channel or not for_publish:
                post = broadcast_format_for_adn(self, entry)
                posts += [(post, 'channel')]

        raise ndb.Return(posts)
コード例 #2
0
    def format_entry_for_adn(self, entry, for_publish=False):
        posts = []
        if (not self.channel_id
                or (self.channel_id and self.publish_to_stream)):
            if for_publish and not entry.published_post or not for_publish:
                post = yield format_for_adn(self, entry)
                posts += [(post, 'post')]

        if self.channel_id and not entry.published_channel:
            if for_publish and not entry.published_channel or not for_publish:
                post = broadcast_format_for_adn(self, entry)
                posts += [(post, 'channel')]

        raise ndb.Return(posts)
コード例 #3
0
    def _immediate_publish(self, entry, in_transaction=False):
        if (self.feed.publish_to_stream or not self.feed.channel_id) and (not entry.published_post or self.ignore_publish_state):
            entry.published_post = True
            data = yield format_for_adn(self.feed, entry)
            path = 'posts'
            deferred.defer(publish_to_api, entry.key.urlsafe(), self.feed.key.urlsafe(), path, data,
                           self.user.access_token, _transactional=in_transaction, _retry_options=api_publish_opts,
                           _target='backend', _url='/api/backend/deferred/task')

        if self.feed.channel_id and (not entry.published_channel or self.ignore_publish_state):
            entry.published_channel = True
            data = broadcast_format_for_adn(self.feed, entry)
            path = 'channels/%s/messages' % self.feed.channel_id
            deferred.defer(publish_to_api, entry.key.urlsafe(), self.feed.key.urlsafe(), path, data,
                           self.user.access_token, _transactional=in_transaction, _retry_options=api_publish_opts,
                           _target='backend', _url='/api/backend/deferred/task')

        entry.published = True
        entry.published_at = datetime.now()
        yield entry.put_async()