當前位置: 首頁>>代碼示例>>Python>>正文


Python Feed.get_for_user方法代碼示例

本文整理匯總了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}
開發者ID:nate-parrott,項目名稱:fast-news,代碼行數:26,代碼來源:api.py

示例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
開發者ID:nate-parrott,項目名稱:fast-news,代碼行數:6,代碼來源:api.py

示例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)
開發者ID:nate-parrott,項目名稱:fast-news,代碼行數:6,代碼來源:api.py

示例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()
開發者ID:nate-parrott,項目名稱:fast-news,代碼行數:8,代碼來源:tasks.py


注:本文中的feed.Feed.get_for_user方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。