本文整理汇总了Python中feed.Feed.get_for_user方法的典型用法代码示例。如果您正苦于以下问题:Python Feed.get_for_user方法的具体用法?Python Feed.get_for_user怎么用?Python Feed.get_for_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feed.Feed
的用法示例。
在下文中一共展示了Feed.get_for_user方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _subscribe_multi
# 需要导入模块: from feed import Feed [as 别名]
# 或者: from feed.Feed import get_for_user [as 别名]
def _subscribe_multi(uid, urls):
sources = {url: ensure_source(url) for url in urls}
# TODO: make 4 a shared value
source_json_futures = {url: source.json(include_articles=True, return_promise=True, article_limit=4) for url, source in sources.iteritems()}
source_json = {url: f() for url, f in source_json_futures.iteritems()}
source_json = {url: source_json for url, source_json in source_json.iteritems() if len(source_json['articles'])}
subscription_futures = {url: Subscription.get_or_insert_async(Subscription.id_for_subscription(source.url, uid)) for url, source in sources.iteritems()}
subscriptions = {url: f.get_result() for url, f in subscription_futures.iteritems()}
for url, sub in subscriptions.iteritems():
canonical_url = sources[url].url
sub.url = canonical_url
sub.uid = uid
ndb.put_multi(subscriptions.values())
Feed.get_for_user(uid).update_in_place(just_added_sources_json=source_json.values())
sub_json_promises = {url: sub.json(return_promise=True) for url, sub in subscriptions.iteritems()}
sub_jsons = {url: f() for url, f in sub_json_promises.iteritems()}
return {"source_jsons": source_json, "subscription_jsons": sub_jsons}
示例2: unsubscribe
# 需要导入模块: from feed import Feed [as 别名]
# 或者: from feed.Feed import get_for_user [as 别名]
def unsubscribe(uid, url):
ndb.Key(Subscription, Subscription.id_for_subscription(url, uid)).delete()
Feed.get_for_user(uid).update_in_place(just_removed_source_urls=[url])
return True
示例3: feed
# 需要导入模块: from feed import Feed [as 别名]
# 或者: from feed.Feed import get_for_user [as 别名]
def feed(uid, force=False):
users.ensure_user_exists(uid)
f = Feed.get_for_user(uid)
return f.ensure_feed_content(force=force)
示例4: post
# 需要导入模块: from feed import Feed [as 别名]
# 或者: from feed.Feed import get_for_user [as 别名]
def post(self):
# TODO: wrap in try-catch
feed = Feed.get_for_user(self.request.get('uid'))
print 'Updating feed for user', self.request.get('uid')
feed.update()
feed.schedule_update()