当前位置: 首页>>代码示例>>Python>>正文


Python Config.get方法代码示例

本文整理汇总了Python中models.Config.get方法的典型用法代码示例。如果您正苦于以下问题:Python Config.get方法的具体用法?Python Config.get怎么用?Python Config.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Config的用法示例。


在下文中一共展示了Config.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: new_feed_worker

# 需要导入模块: from models import Config [as 别名]
# 或者: from models.Config import get [as 别名]
def new_feed_worker(url, favicon_dir, answer_box, manager_box):
    logger.info("Fetching feed... [%s]", url)
    try:
        fetched = fetch_and_parse_feed(url)
        feed_dict, real_url = fetched['feed'], fetched['real_url']
    except FetchingException:
        return answer_box.put(Exception("Error with feed: " + url))

    feed = FeedFromDict(feed_dict, Config.get())
    feed.url = sanitize_url(real_url) # set the real feed url
    logger.info("Fetching favicon... [%s]", feed.url)
    feed.favicon_path = save_favicon(fetch_favicon(feed.url), favicon_dir)
    db.session.add(feed)
    for e in feed_dict['entries'][::-1]:
        entry = EntryFromDict(e, feed.url)
        entry.feed = feed # set the corresponding feed
        db.session.add(entry)
    db.session.commit()

    most_recent_entry = feed.entries.order_by(Entry.updated.desc()).first()
    feed.updated = most_recent_entry.updated
    db.session.commit()

    answer_box.put(feed)
    manager_box.put({'type': 'new-deadline-worker', 'feed_id': feed.id})
    manager_box.put({'type': 'refresh-cache', 'feed_id': feed.id})
开发者ID:fspot,项目名称:zenfeed,代码行数:28,代码来源:workers.py

示例2: api_edit_config

# 需要导入模块: from models import Config [as 别名]
# 或者: from models.Config import get [as 别名]
def api_edit_config():
    config = Config.get()
    # update all fields, no checks (TODO)
    config_fields = config.fields_set(exclude_fields=['id', 'password'])
    fields = config_fields & set(request.json.keys())
    for field in fields:
        setattr(config, field, request.json[field])
    # change password if the "pw" field isnt empty
    pw = request.json.get('pw')
    if pw:
        Config.change_password(pw)
    db.session.merge(config)
    db.session.commit()
    Config.refresh_instance()  # not necessary ?
    return jsonify({'msg': 'Success !'})
开发者ID:fspot,项目名称:zenfeed,代码行数:17,代码来源:views.py

示例3: fetching_work

# 需要导入模块: from models import Config [as 别名]
# 或者: from models.Config import get [as 别名]
def fetching_work(feed, manager_box):
    fetched = fetch_and_parse_feed(feed.url)
    feed_dict, real_url = fetched['feed'], fetched['real_url']
    if feed.url != real_url:
        logger.warning("©©© Feed url changed from %s to %s", feed.url, real_url)
        feed.url = sanitize_url(real_url)
    logger.info("©©© Updated feed: %s", feed.url)
    feed_changed = update_feed(feed, FeedFromDict(feed_dict, Config.get()))
    any_entry_created = any([
        create_or_update_entry(feed.id, EntryFromDict(e, feed.url))
        for e in feed_dict['entries']
    ])
    db.session.commit()

    if any_entry_created:
        most_recent_entry = feed.entries.order_by(Entry.updated.desc()).first()
        feed.updated = most_recent_entry.updated
        feed.has_news = feed.has_news or feed.highlight_news
        db.session.merge(feed)
        db.session.commit()
        manager_box.put({'type': 'refresh-cache', 'feed_id': feed.id})
开发者ID:fspot,项目名称:zenfeed,代码行数:23,代码来源:workers.py

示例4: api_get_config

# 需要导入模块: from models import Config [as 别名]
# 或者: from models.Config import get [as 别名]
def api_get_config():
    config = Config.get()
    return jsonify(config.to_dict(exclude_fields=['password', 'id']))
开发者ID:fspot,项目名称:zenfeed,代码行数:5,代码来源:views.py


注:本文中的models.Config.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。