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


Python AtomFeed.updated方法代码示例

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


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

示例1: lang_feed

# 需要导入模块: from werkzeug.contrib.atom import AtomFeed [as 别名]
# 或者: from werkzeug.contrib.atom.AtomFeed import updated [as 别名]
def lang_feed(lang):
    """generate atom feed for blog entries in the specific language"""
    blog_entries = db.session.query(BlogEntry).filter_by(lang = lang).order_by(BlogEntry.created.desc()).limit(PAGE_SIZE)
    updated = blog_entries.first().created if blog_entries.count() > 0 else ''

    etag = '"{0}"'.format(hashlib.sha256(str(updated)).hexdigest())
    if request.headers.get('If-None-Match', '') == etag:
        return '', 304
    last_modified = format_date_time(mktime(updated.timetuple()))
    if request.headers.get('If-Modified-Since', '') == last_modified:
        return '', 304

    title = app.config['BLOG_OWNER'] + "'s Thoughts and Writings"
    if lang == 'cn':
        title = app.config['BLOG_OWNER'] + u'的博客'
    feed = AtomFeed(title = title, 
                    url = request.url_root, 
                    feed_url = request.url, 
                    author = app.config['BLOG_OWNER'])
    if updated:
        feed.updated = updated
    for blog_entry in blog_entries:
        feed.add(title = blog_entry.title, 
                 content = unicode(blog_entry.content),
                 content_type = 'html',
                 author = app.config['BLOG_OWNER'],
                 url = urljoin(request.url_root, url_for('blog_entry.read', uid = blog_entry.uid)),
                 updated = blog_entry.updated,
                 published = blog_entry.created)
    
    response = feed.get_response()
    response.headers['ETag'] = etag
    response.headers['Last-Modified'] = last_modified
    return response
开发者ID:askender,项目名称:everblog,代码行数:36,代码来源:blog_entry.py


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