當前位置: 首頁>>代碼示例>>Python>>正文


Python Source.name方法代碼示例

本文整理匯總了Python中source.Source.name方法的典型用法代碼示例。如果您正苦於以下問題:Python Source.name方法的具體用法?Python Source.name怎麽用?Python Source.name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在source.Source的用法示例。


在下文中一共展示了Source.name方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: transactionalCreateTree

# 需要導入模塊: from source import Source [as 別名]
# 或者: from source.Source import name [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']
開發者ID:aaronlifshin,項目名稱:howtosavedemocaracy,代碼行數:56,代碼來源:point.py


注:本文中的source.Source.name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。