本文整理汇总了Python中models.Topic.get_by_title_and_parent方法的典型用法代码示例。如果您正苦于以下问题:Python Topic.get_by_title_and_parent方法的具体用法?Python Topic.get_by_title_and_parent怎么用?Python Topic.get_by_title_and_parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Topic
的用法示例。
在下文中一共展示了Topic.get_by_title_and_parent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: recursive_copy_topic_list_structure
# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import get_by_title_and_parent [as 别名]
def recursive_copy_topic_list_structure(parent, topic_list_part):
delete_topics = {}
for topic_dict in topic_list_part:
logging.info(topic_dict["name"])
if "playlist" in topic_dict:
topic = Topic.get_by_title_and_parent(topic_dict["name"], parent)
if topic:
logging.info(topic_dict["name"] + " is already created")
else:
version = TopicVersion.get_edit_version()
root = Topic.get_root(version)
topic = Topic.get_by_title_and_parent(topic_dict["playlist"], root)
if topic:
delete_topics[topic.key()] = topic
logging.info("copying %s to parent %s" %
(topic_dict["name"], parent.title))
topic.copy(title=topic_dict["name"], parent=parent,
standalone_title=topic.title)
else:
logging.error("Topic not found! %s" % (topic_dict["playlist"]))
else:
topic = Topic.get_by_title_and_parent(topic_dict["name"], parent)
if topic:
logging.info(topic_dict["name"] + " is already created")
else:
logging.info("adding %s to parent %s" %
(topic_dict["name"], parent.title))
topic = Topic.insert(title=topic_dict["name"], parent=parent)
if "items" in topic_dict:
delete_topics.update(
recursive_copy_topic_list_structure(topic,
topic_dict["items"]))
return delete_topics