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


Python Topic.get_content_topics方法代码示例

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


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

示例1: topic_title_dicts

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import get_content_topics [as 别名]
def topic_title_dicts(version_number=None):
    if version_number:
        version = TopicVersion.get_by_number(version_number)
    else:
        version = None

    return [{
        "title": topic.standalone_title,
        "key": str(topic.key()),
        "relative_url": "/%s" % topic.relative_url,
        "id": topic.id
    } for topic in Topic.get_content_topics(version=version)]
开发者ID:johnfelipe,项目名称:server,代码行数:14,代码来源:autocomplete.py

示例2: copyTopicsToPlaylist

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import get_content_topics [as 别名]
    def copyTopicsToPlaylist(self):
        topic_list = Topic.get_content_topics()

        for topic in topic_list:
            playlist = Playlist.all().filter("title =", topic.standalone_title).get()
            if playlist:
                logging.info("Copying topic " + topic.standalone_title + " to playlist.")
                child_keys = topic.child_keys
                vps = VideoPlaylist.all().filter("playlist =", playlist).order("video_position").fetch(10000)

                playlist_keys = []
                for vp in vps:
                    try:
                        playlist_keys.append(vp.video.key())
                    except db.ReferencePropertyResolveError:
                        logging.info("Found reference to missing video in VideoPlaylist!")

                topic_keys = [key for key in topic.child_keys if key.kind() == "Video"]

                if playlist_keys == topic_keys:
                    logging.info("Child keys identical. No changes will be made.")
                else:
#                    logging.info("PLAYLIST: " + repr([str(key) for key in playlist_keys]))
#                    logging.info("TOPIC:    " + repr([str(key) for key in topic_keys]))

                    logging.info("Deleting old VideoPlaylists...")
                    db.delete(vps)

                    vps = []
                    for i, child_key in enumerate(topic.child_keys):
                        if child_key.kind() == "Video":
                            vps.append(VideoPlaylist(
                                video=child_key,
                                playlist=playlist,
                                video_position=i,
                                live_association = True
                                ))

                    logging.info("Creating new VideoPlaylists...")
                    db.put(vps)
            else:
                logging.info("Playlist matching topic " + topic.standalone_title + " not found.")
开发者ID:johnfelipe,项目名称:server,代码行数:44,代码来源:youtube_sync.py


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