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


Python ArticleController.values方法代碼示例

本文整理匯總了Python中web.controllers.ArticleController.values方法的典型用法代碼示例。如果您正苦於以下問題:Python ArticleController.values方法的具體用法?Python ArticleController.values怎麽用?Python ArticleController.values使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在web.controllers.ArticleController的用法示例。


在下文中一共展示了ArticleController.values方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_menu

# 需要導入模塊: from web.controllers import ArticleController [as 別名]
# 或者: from web.controllers.ArticleController import values [as 別名]
def get_menu():
    categories_order = [0]
    categories = {0: {'name': 'No category', 'id': 0}}
    for cat in CategoryController(current_user.id).read().order_by('name'):
        categories_order.append(cat.id)
        categories[cat.id] = cat
    unread = ArticleController(current_user.id).count_by_feed(readed=False)
    for cat_id in categories:
        categories[cat_id]['unread'] = 0
        categories[cat_id]['feeds'] = []
    feeds = {feed.id: feed for feed in FeedController(current_user.id).read()}
    for feed_id, feed in feeds.items():
        feed['created_stamp'] = timegm(feed.created_date.timetuple()) * 1000
        feed['last_stamp'] = timegm(feed.last_retrieved.timetuple()) * 1000
        feed['category_id'] = feed.category_id or 0
        feed['unread'] = unread.get(feed.id, 0)
        if not feed.filters:
            feed['filters'] = []
        if feed.icon_url:
            feed['icon_url'] = url_for('icon.icon', url=feed.icon_url)
        categories[feed['category_id']]['unread'] += feed['unread']
        categories[feed['category_id']]['feeds'].append(feed_id)
    return {'feeds': feeds, 'categories': categories,
            'categories_order': categories_order,
            'crawling_method': conf.CRAWLING_METHOD,
            'max_error': conf.DEFAULT_MAX_ERROR,
            'error_threshold': conf.ERROR_THRESHOLD,
            'is_admin': current_user.is_admin,
            'all_unread_count': sum(unread.values())}
開發者ID:blatinier,項目名稱:JARR,代碼行數:31,代碼來源:home.py

示例2: get_menu

# 需要導入模塊: from web.controllers import ArticleController [as 別名]
# 或者: from web.controllers.ArticleController import values [as 別名]
def get_menu():
    now, locale = datetime.now(), get_locale()
    categories_order = [0]
    categories = {0: {'name': 'No category', 'id': 0}}
    for cat in CategoryController(current_user.id).read().order_by('name'):
        categories_order.append(cat.id)
        categories[cat.id] = cat
    unread = ArticleController(current_user.id).count_by_feed(readed=False)
    for cat_id in categories:
        categories[cat_id]['unread'] = 0
        categories[cat_id]['feeds'] = []
    feeds = {feed.id: feed for feed in FeedController(current_user.id).read()}
    for feed_id, feed in feeds.items():
        feed['created_rel'] = format_timedelta(feed.created_date - now,
                add_direction=True, locale=locale)
        feed['last_rel'] = format_timedelta(feed.last_retrieved - now,
                add_direction=True, locale=locale)
        feed['created_date'] = format_datetime(localize(feed.created_date),
                                               locale=locale)
        feed['last_retrieved'] = format_datetime(localize(feed.last_retrieved),
                                                 locale=locale)
        feed['category_id'] = feed.category_id or 0
        feed['unread'] = unread.get(feed.id, 0)
        if not feed.filters:
            feed['filters'] = []
        if feed.icon_url:
            feed['icon_url'] = url_for('icon.icon', url=feed.icon_url)
        categories[feed['category_id']]['unread'] += feed['unread']
        categories[feed['category_id']]['feeds'].append(feed_id)
    return {'feeds': feeds, 'categories': categories,
            'categories_order': categories_order,
            'crawling_method': conf.CRAWLER_TYPE,
            'max_error': conf.FEED_ERROR_MAX,
            'error_threshold': conf.FEED_ERROR_THRESHOLD,
            'is_admin': current_user.is_admin,
            'all_unread_count': sum(unread.values())}
開發者ID:jaesivsm,項目名稱:JARR,代碼行數:38,代碼來源:home.py

示例3: execute

# 需要導入模塊: from web.controllers import ArticleController [as 別名]
# 或者: from web.controllers.ArticleController import values [as 別名]
 def execute(self):
     counts = ArticleController(ignore_context=True).count_by_user_id()
     print("articles.value %s" % sum(counts.values()))
     for user, count in counts.items():
         print("articles_user_%s.value %s" % (user, count))
開發者ID:blatinier,項目名稱:JARR,代碼行數:7,代碼來源:probes.py


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