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


Python Entry.show_in_rss方法代码示例

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


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

示例1: import_from_json

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import show_in_rss [as 别名]
def import_from_json(data, show=False):
    ret = []

    if show:
        print len([i for i in Entry.all()])

    # Deserialize
    objects = simplejson.loads(data)

    for obj in objects:
        if obj['model'] != 'blog.entry':
            continue

        #if obj['fields']['media_type'] == 'I':
        #    print "'%s': %s"%(obj['fields']['slug'], obj['pk'])
        #continue

        if obj['fields']['media_type'] != 'P' or not obj['fields']['published']:
            continue

        msg = '%d %s'%(obj['pk'], obj['fields']['title'])
        if show:
            print msg
        else:
            ret.append(msg)

        # Blog entry
        try:
            entry = Entry.all().filter('old_id =', int(obj['pk']))[0]
        except IndexError:
            entry = Entry()

        entry.old_id = obj['pk']

        m = RE_DATETIME.match(obj['fields']['pub_date'])
        groups = [int(i) for i in m.groups()]
        entry.pub_date = datetime.datetime(*groups)

        entry.title = obj['fields']['title']
        entry.description = obj['fields']['description']
        entry.format = obj['fields']['format']
        entry.published = True
        entry.show_in_rss = False
        entry.slug = obj['fields']['slug']
        entry.tags = [db.Category(TAGS[tag]) for tag in obj['fields']['tags']]

        text = obj['fields']['content']
        text = text.replace('http://media.marinhobrandao.com/','/')

        f = RE_IMG_URL.findall(text)
        rep = []

        for url in f:
            m = RE_IMG_URL2.match(url)
            new_url = '/media/img/upload/%s'%IMAGES[m.group(1)]

            if show:
                print '\t', new_url

            text = text.replace(url, new_url)

        entry.text = text

        entry.save()

        # Gallery image

    msg = [i.slug for i in Entry.all()]
    if show:
        print msg
    else:
        ret.append(' '.join([i for i in msg]))
开发者ID:BrianPainter,项目名称:geraldo,代码行数:74,代码来源:migration.py


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