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


Python Feed.get_by_id方法代码示例

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


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

示例1: get

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import get_by_id [as 别名]
    def get(self):

        feed_id, feed_url = self.request.get('feed_id'), \
                self.request.get('feed_url')

        url_result = urllib2.urlopen(feed_url)
        feed_result = fd.parse(url_result)

        if feed_result.bozo == 1:
            logging.error('fetch error, id: %s, url: %s, error: %s', 
                    feed_id, feed_url, feed_result.bozo_exception)
            return

        feed_update_time = feed_result.get('updated', datetime.utcnow)
        has_update = True 

        f = Feed.get_by_id(int(feed_id))
        if f.is_allow_fetch(feed_update_time):
            for entry in feed_result.entries:
                if entry.published_parsed <= f.lastedPublishedTime:
                    logging.info('no updated, id: %s, url: %s', feed_id,
                            feed_url)
                    has_update = False
                    break

                e = Entry(title = entry.title,
                          url = entry.link,
                          author = entry.author,
                          content = entry.content),
                          publishedTime = entry.published_parsed)
                e.put()
                logging.debug('fetch entry, url: %s', entry.link)
开发者ID:tonychi,项目名称:readLater,代码行数:34,代码来源:work.py

示例2: get_feed

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import get_by_id [as 别名]
def get_feed(feed_id):
    """ Retrieve a feed from memcache or generate it if it does not exist """
    xml = memcache.get(feed_id) # In memcache?
    if xml is None:
        feed = Feed.get_by_id(int(feed_id))
        rss = None
        if feed:
            if feed.public_board:
                rss = TrelloRSS(
                    constants.KEY,
                    channel_title=feed.channel_title,
                    rss_channel_link=feed.channel_link,
                    description=feed.channel_description)
            else:
                user = feed.user.get()
                rss = TrelloRSS(
                    constants.KEY,
                    token=user.auth_token,
                    channel_title=feed.channel_title,
                    rss_channel_link=feed.channel_link,
                    description=feed.channel_description)
            if feed.get_all:
                if feed.actions:
                    rss.get_all(items=feed.actions)
                else:
                    rss.get_all()
            else:
                if feed.actions:
                    rss.get_from(feed.board_id,public_board=feed.public_board,items=feed.actions)
                else:
                    rss.get_from(feed.board_id,public_board=feed.public_board)
            xml = rss.rss
            memcache.add(key=feed_id, value=xml, time=1800) # Expire after 30 minutes
    return xml
开发者ID:naiyt,项目名称:trellorss-gae,代码行数:36,代码来源:utils.py

示例3: published_entries_for_feed

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import get_by_id [as 别名]
def published_entries_for_feed(feed_id):
    feed = Feed.get_by_id(feed_id, parent=g.user.key)
    if not feed:
        return jsonify_error(message="Can't find that feed")

    feed_data = feed.to_json()
    entries = [entry.to_json(include=['title', 'link', 'published', 'published_at']) for entry in Entry.latest_published(feed).fetch(20)]
    feed_data['entries'] = entries

    return jsonify(status='ok', data=feed_data)
开发者ID:voidfiles,项目名称:pourover,代码行数:12,代码来源:views.py

示例4: delete_feed

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import get_by_id [as 别名]
def delete_feed(feed_id):
    """Get a feed"""
    feed = Feed.get_by_id(feed_id, parent=g.user.key)
    if not feed:
        return jsonify_error(message="Can't find that feed")

    Entry.delete_for_feed(feed)
    feed.key.delete()

    return jsonify(status='ok')
开发者ID:voidfiles,项目名称:pourover,代码行数:12,代码来源:views.py

示例5: feed

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import get_by_id [as 别名]
def feed(feed_id):
    """Get a feed"""
    feed = Feed.get_by_id(feed_id, parent=g.user.key)
    if not feed:
        return jsonify_error(message="Can't find that feed")

    feed_data = feed.to_json()
    entries = [entry.to_dict(include=['guid', 'published', 'extra_info']) for entry in Entry.latest_for_feed(feed).fetch(10)]
    feed_data['entries'] = entries

    return jsonify(status='ok', data=feed_data)
开发者ID:voidfiles,项目名称:pourover,代码行数:13,代码来源:views.py

示例6: admin_feed_form

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import get_by_id [as 别名]
def admin_feed_form(request, feed_id=None):
    if feed_id:
        feed = Feed.get_by_id(int(feed_id))
    else:
        feed = None
    if request.method == "POST":
        form = FeedForm(request.POST, instance=feed)
        if form.is_valid():
            feed = form.save(commit=False)
            feed.save()
            return HttpResponseRedirect("../")
    else:
        form = FeedForm(instance=feed)
    return render_to_response("planet/admin_feed_form.html", {"feed_id": feed_id, "form": form})
开发者ID:nakagami,项目名称:planetgae,代码行数:16,代码来源:views.py

示例7: save_feed_preview

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import get_by_id [as 别名]
def save_feed_preview(feed_id):
    """preview a saved feed"""
    form = FeedUpdate(request.args)
    if not form.validate():
        return jsonify_error(message="Invalid update data")

    feed = Feed.get_by_id(feed_id, parent=g.user.key)
    if not feed:
        return jsonify_error(message="Can't find that feed")

    form.populate_obj(feed)
    feed.preview = True
    preview_entries = Entry.entry_preview(Entry.latest_published(feed).fetch(3), feed, format=True)

    return jsonify(status='ok', data=preview_entries)
开发者ID:voidfiles,项目名称:pourover,代码行数:17,代码来源:views.py

示例8: feed_entry_publish

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import get_by_id [as 别名]
def feed_entry_publish(feed_id, entry_id):
    """Get a feed"""
    logger.info('Manually publishing Feed:%s Entry: %s', feed_id, entry_id)

    feed = Feed.get_by_id(feed_id, parent=g.user.key)
    if not feed:
        return jsonify_error(message="Can't find that feed")

    entry = Entry.get_by_id(entry_id, parent=feed.key)
    if not entry:
        return jsonify_error(message="Can't find that entry")

    entry.publish_entry(feed)
    entry.overflow = False
    entry.put()

    return jsonify(status='ok')
开发者ID:voidfiles,项目名称:pourover,代码行数:19,代码来源:views.py

示例9: feed_change

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import get_by_id [as 别名]
def feed_change(feed_id):
    """Get a feed"""
    form = FeedUpdate(request.form)
    if not form.validate():
        return jsonify_error(message="Invalid update data")

    feed = Feed.get_by_id(feed_id, parent=g.user.key)
    if not feed:
        return jsonify_error(message="Can't find that feed")

    form.populate_obj(feed)
    feed.put()

    feed_data = feed.to_json()
    entries = [entry.to_dict(include=['title', 'link', 'published', 'published_at']) for entry in Entry.latest_for_feed(feed).fetch(10)]
    feed_data['entries'] = entries

    return jsonify(status='ok', data=feed_data)
开发者ID:voidfiles,项目名称:pourover,代码行数:20,代码来源:views.py

示例10: feed_entry_publish

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import get_by_id [as 别名]
def feed_entry_publish(feed_id, entry_id):
    """Get a feed"""
    logger.info('Manually publishing Feed:%s Entry: %s', feed_id, entry_id)

    key = ndb.Key(urlsafe=entry_id)
    feed = Feed.get_by_id(feed_id, parent=g.user.key)
    if not (feed and key.parent() == feed.key):
        return jsonify_error(message="Can't find that feed")

    entry = key.get()
    if not entry:
        return jsonify_error(message="Can't find that entry")

    entry.publish_entry(feed).get_result()
    entry.overflow = False
    entry.put()

    return jsonify(status='ok')
开发者ID:berg,项目名称:pourover,代码行数:20,代码来源:views.py

示例11: admin_feed_cleanup

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import get_by_id [as 别名]
def admin_feed_cleanup(request, feed_id):
    feed = Feed.get_by_id(int(feed_id))
    for e in db.Query(Entry).filter("feed", feed):
        e.delete()
    return HttpResponseRedirect("../")
开发者ID:nakagami,项目名称:planetgae,代码行数:7,代码来源:views.py


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