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


Python Source.constructFromArrays方法代碼示例

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


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

示例1: transactionalCreate

# 需要導入模塊: from source import Source [as 別名]
# 或者: from source.Source import constructFromArrays [as 別名]
    def transactionalCreate(pointRoot, title, nodetype, content, summaryText, user,
                            imageURL=None, imageAuthor=None, 
                            imageDescription=None, sourceURLs=None, sourceNames=None):
        pointRoot.put()
        point = Point(parent=pointRoot.key)
        point.title = title
        point.nodetype = nodetype        
        point.url = pointRoot.url
        point.content = content
        point.summaryText = summaryText if (len(
            summaryText) != 250) else summaryText + '...'
        point.authorName = user.name
        point.authorURL = user.url
        point.version = 1
        point.current = True
        point.upVotes = 1
        point.downVotes = 0
        point.voteTotal = 1
        point.imageURL = imageURL
        point.imageDescription = imageDescription
        point.imageAuthor = imageAuthor
        point.put() 
        sources = Source.constructFromArrays(sourceURLs, sourceNames, point.key)
        if sources:
            sourceKeys = []
            for source in sources:
                source.put()
                sourceKeys = sourceKeys + [source.key]
            point.sources = sourceKeys
        point.put()
        point.addToSearchIndexNew()

        pointRoot.current = point.key
        pointRoot.put()

        user.addVote(point, voteValue=1, updatePoint=False)
        user.recordCreatedPoint(pointRoot.key)
        
        return point, pointRoot
開發者ID:aaronlifshin,項目名稱:howtosavedemocaracy,代碼行數:41,代碼來源:point.py


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