本文整理汇总了Python中source.Source.put方法的典型用法代码示例。如果您正苦于以下问题:Python Source.put方法的具体用法?Python Source.put怎么用?Python Source.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类source.Source
的用法示例。
在下文中一共展示了Source.put方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transactionalCreateTree
# 需要导入模块: from source import Source [as 别名]
# 或者: from source.Source import put [as 别名]
def transactionalCreateTree(dataForPointTree, user):
outlineRoot = OutlineRoot()
outlineRoot.put()
# ITERATE THE FIRST TIME AND CREATE ALL POINT ROOTS WITH BACKLINKS
for p in dataForPointTree:
pointRoot = PointRoot(parent=outlineRoot.key)
pointRoot.url = p['url']
pointRoot.numCopies = 0
pointRoot.editorsPick = False
pointRoot.viewCount = 1
if 'parentIndex' in p:
parentPointRoot = dataForPointTree[p['parentIndex']]['pointRoot']
pointRoot.pointsSupportedByMe = [parentPointRoot.key]
pointRoot.put()
p['pointRoot'] = pointRoot
point = Point(parent=pointRoot.key)
point.title = p['title']
point.url = pointRoot.url
point.content = p['furtherInfo']
point.current = True
point.authorName = user.name
point.authorURL = user.url
point.put()
user.addVote(point, voteValue=1, updatePoint=False)
user.recordCreatedPoint(pointRoot.key)
p['point'] = point
p['pointRoot'].current = p['point'].key
pointRoot.put()
point.addToSearchIndexNew()
# ITERATE THE SECOND TIME ADD SUPPORTING POINTS
for p in dataForPointTree:
if 'parentIndex' in p:
linkP = dataForPointTree[p['parentIndex']]['point']
linkP.supportingPointsRoots = linkP.supportingPointsRoots + [p['pointRoot'].key] \
if linkP.supportingPointsRoots else [p['pointRoot'].key]
linkP.supportingPointsLastChange = linkP.supportingPointsLastChange + [p['point'].key] \
if linkP.supportingPointsRoots else [p['point'].key]
# ITERATE THE THIRD TIME AND WRITE POINTS WITH ALL SUPPORTING POINTS AND SOURCE KEYS
for p in dataForPointTree:
if p['sources']:
sourceKeys = []
for s in p['sources']:
source = Source(parent=p['point'].key)
source.url = s['sourceURL']
source.name = s['sourceTitle']
source.put()
sourceKeys = sourceKeys + [source.key]
p['point'].sources = sourceKeys
p['point'].put()
return dataForPointTree[0]['point'], dataForPointTree[0]['pointRoot']