本文整理匯總了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()