本文整理汇总了Python中models.Entry.publish_for_feed方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.publish_for_feed方法的具体用法?Python Entry.publish_for_feed怎么用?Python Entry.publish_for_feed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Entry
的用法示例。
在下文中一共展示了Entry.publish_for_feed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_all_feeds
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import publish_for_feed [as 别名]
def post_all_feeds():
"""Post all new items for feeds for a specific interval"""
if request.headers.get('X-Appengine-Cron') != 'true':
raise ndb.Return(jsonify_error(message='Not a cron call'))
feed_classes = (Feed, InstagramFeed)
iterators = [x.query().iter() for x in feed_classes]
errors = 0
success = 0
num_posted = 0
futures = []
for iterator in iterators:
while (yield iterator.has_next_async()):
feed = iterator.next()
futures.append((feed, Entry.publish_for_feed(feed)))
for feed, future in futures:
try:
num_posts = yield future
if num_posts is not None:
num_posted += num_posts
success += 1
except:
errors += 1
logger.exception('Failed to Publish feed:%s' % (feed.feed_url, ))
stat = yield write_epoch_to_stat(Stat, 'post_job')
logger.info('Post Feeds success:%s errors: %s num_posted: %s', success, errors, num_posted)
raise ndb.Return(jsonify(status='ok'))
示例2: feed_push_update
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import publish_for_feed [as 别名]
def feed_push_update(feed_key):
feed = ndb.Key(urlsafe=feed_key).get()
if not feed:
raise ndb.Return(("No feed", 404))
data = request.stream.read()
if feed.hub_secret:
server_signature = request.headers.get('X-Hub-Signature', None)
signature = hmac.new(feed.hub_secret, data).hexdigest()
if server_signature != signature:
logger.warn('Got PuSH subscribe POST for feed key=%s w/o valid signature: sent=%s != expected=%s', feed_key,
server_signature, signature)
raise ndb.Return('')
logger.info('Got PuSH body: %s', data)
logger.info('Got PuSH headers: %s', request.headers)
parsed_feed = feedparser.parse(data)
new_guids, old_guids = yield Entry.process_parsed_feed(parsed_feed, feed, overflow=False)
yield Entry.publish_for_feed(feed, skip_queue=False)
raise ndb.Return('')