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


Python point.Point类代码示例

本文整理汇总了Python中models.point.Point的典型用法代码示例。如果您正苦于以下问题:Python Point类的具体用法?Python Point怎么用?Python Point使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getPointCreator

 def getPointCreator(self):
     result = {'result': False}
     point, pointRoot = Point.getCurrentByUrl(self.request.get('pointURL'))
     versionsOfThisPoint = Point.query(ancestor=pointRoot.key).order(Point.version)
     firstVersion = versionsOfThisPoint.get()
     
     authors = []
     """code for listing number of contributors"""
     """
     for point in versionsOfThisPoint:
         thisAuthor = {"authorName": point.authorName, "authorURL": point.authorURL }
         if thisAuthor not in authors:
             authors.append(thisAuthor)
     """                
     
     resultJSON = json.dumps({
                 'result': True, 
                 'creatorName' : firstVersion.authorName,
                 'creatorURL'  : firstVersion.authorURL,
                 'numAuthors'  : len(authors)
             })
     self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
     self.response.out.write(resultJSON) 
     
     
     
     
     
开发者ID:aaronlifshin,项目名称:whysaurus,代码行数:23,代码来源:pointhistory.py

示例2: get

 def get(self):
     user = self.current_user
     linkType = 'supporting'
     p1, pRoot1 = Point.getCurrentByUrl('CCC')
     p2, pRoot2 = Point.getCurrentByUrl('bbb')
     
     #result, newRelevance, newVoteCount = \        
     #    user.addRelevanceVote(pRoot1.key.urlsafe(), pRoot2.key.urlsafe(), linkType, 50) 
     """newRelVote = RelevanceVote(
         parent=user.key,
         parentPointRootKey = pRoot1.key,
         childPointRootKey = pRoot2.key,
         value = 50,
         linkType=linkType)
     newRelVote.put()"""
         
     # GET THE VOTE BACK
     q = RelevanceVote.query(RelevanceVote.parentPointRootKey == pRoot1.key,
        RelevanceVote.childPointRootKey == pRoot2.key, 
        RelevanceVote.linkType == linkType)
     votes = q.fetch(20)       
     message = ""
     message = 'Got %d votes on retrieval.' % len(votes) 
     template_values = {
         'user': user,
         'message': message,            
         'currentArea':self.session.get('currentArea'),
         'currentAreaDisplayName':self.session.get('currentAreaDisplayName')    
     }
     self.response.out.write(self.template_render('message.html', template_values))        
开发者ID:aaronlifshin,项目名称:whysaurus,代码行数:30,代码来源:testpage.py

示例3: post

    def post(self):
        resultJSON = json.dumps({'result': False})
        supportingPoint, supportingPointRoot = Point.getCurrentByUrl(self.request.get('supportingPointURL'))
        oldPoint, oldPointRoot = Point.getCurrentByUrl(self.request.get('parentPointURL'))
        user = self.current_user
        linkType = self.request.get('linkType')

        if user:
            try:
                newLink = [{'pointRoot':supportingPointRoot,
                            'pointCurrentVersion':supportingPoint,
                            'linkType':self.request.get('linkType')}
                            ]
                oldPoint.update(
                    pointsToLink=newLink,
                    user=user
                )
            except WhysaurusException as e:
                resultJSON = json.dumps({'result': False, 'error': str(e)})
            else:
                path = os.path.join(constants.ROOT, 'templates/pointBox.html')
                newLinkPointHTML = json.dumps(template.render(path, {'point': supportingPoint}))
                resultJSON = json.dumps({'result': True,
                                         'numLinkPoints': supportingPoint.linkCount(linkType),
                                         'newLinkPoint':newLinkPointHTML})
        else:
            resultJSON = json.dumps({'result': 'ACCESS DENIED!'})
        self.response.headers.add_header('content-type', 'application/json', charset='utf-8')
        self.response.out.write(resultJSON)
开发者ID:aaronlifshin,项目名称:howtosavedemocaracy,代码行数:29,代码来源:linkpoint.py

示例4: post

    def post(self):
        jsonOutput = {'result': False}
        user = self.current_user
        linkType = self.request.get('linkType')
        sourcesURLs=json.loads(self.request.get('sourcesURLs'))
        sourcesNames=json.loads(self.request.get('sourcesNames'))
        parentNewScore = None
        
        if user:   
            try:       
                parentPointURL = self.request.get('pointUrl')
                oldPoint, oldPointRoot = Point.getCurrentByUrl(parentPointURL)
                if oldPointRoot:
                    newPoint, newLinkPoint = Point.addSupportingPoint(
                        oldPointRoot=oldPointRoot,
                        title=self.request.get('title'),
                        content=self.request.get('content'),
                        summaryText=self.request.get('plainText'),
                        user=user,
                        # backlink=oldPoint.key.parent(),
                        linkType = linkType,
                        imageURL=self.request.get('imageURL'),
                        imageAuthor=self.request.get('imageAuthor'),
                        imageDescription=self.request.get('imageDescription'),
                        sourcesURLs=sourcesURLs,
                        sourcesNames=sourcesNames            
                    )

                    # TODO: Gene: Probably have a more efficient retrieval here no?
                    oldPoint, oldPointRoot = Point.getCurrentByUrl(parentPointURL)
                    if oldPoint:
                        parentNewScore = oldPoint.pointValue()
                else:
                    raise WhysaurusException('Point with URL %s not found' % parentPointURL)
            except WhysaurusException as e:
                jsonOutput = {
                    'result': False,
                    'errMessage': str(e)
                }
            else:
                ReportEvent.queueEventRecord(user.key.urlsafe(), newLinkPoint.key.urlsafe(), newPoint.key.urlsafe(), "Create Point")           
                newLinkPointHTML = self.template_render('linkPoint.html', {
                    'point': newLinkPoint,
                    'linkType': linkType
                })
                jsonOutput = {
                    'result': True,
                    'version': newPoint.version,
                    'author': newPoint.authorName,
                    'dateEdited': newPoint.PSTdateEdited.strftime('%b. %d, %Y, %I:%M %p'),
                    'numLinkPoints': newPoint.linkCount(linkType),
                    'newLinkPoint': newLinkPointHTML,
                    'authorURL': self.current_user.url,
                    'parentNewScore': parentNewScore
                }
            self.response.headers["Content-Type"] = 'application/json; charset=utf-8'      
            self.response.out.write(json.dumps(jsonOutput))
        else:
            self.response.out.write('Need to be logged in')
开发者ID:aaronlifshin,项目名称:whysaurus,代码行数:59,代码来源:addsupportingpoint.py

示例5: post

    def post(self):
        jsonOutput = {'result': False}
        oldPoint, oldPointRoot = Point.getCurrentByUrl(
            self.request.get('pointUrl'))
        user = self.current_user
        linkType = self.request.get('linkType')
        nodeType = self.request.get('nodeType') if \
            self.request.get('nodeType') else 'Point'

        sourcesURLs=json.loads(self.request.get('sourcesURLs'))
        sourcesNames=json.loads(self.request.get('sourcesNames'))
        if user:
            newLinkPoint, newLinkPointRoot = Point.create(
                title=self.request.get('title'),
                nodetype=nodeType,
                content=self.request.get('content'),
                summaryText=self.request.get('plainText'),
                user=user,
                backlink=oldPoint.key.parent(),
                linktype = linkType,
                imageURL=self.request.get('imageURL'),
                imageAuthor=self.request.get('imageAuthor'),
                imageDescription=self.request.get('imageDescription'),
                sourceURLs=sourcesURLs,
                sourceNames=sourcesNames)
            try:
                logging.info('Adding newLink: ' + linkType)
                newLinks = [{'pointRoot':newLinkPointRoot,
                            'pointCurrentVersion':newLinkPoint,
                            'linkType':linkType},
                            ]
                newPoint = oldPoint.update(
                    pointsToLink=newLinks,                 
                    user=user
                )
            except WhysaurusException as e:
                jsonOutput = {
                    'result': False,
                    'err': str(e)
                }
            else:
                path = os.path.join(constants.ROOT, 'templates/pointBox.html')
                newLinkPointHTML = json.dumps(template.render(path, {'point': newLinkPoint}))
                jsonOutput = {
                    'result': True,
                    'version': newPoint.version,
                    'author': newPoint.authorName,
                    'dateEdited': newPoint.dateEdited.strftime("%Y-%m-%d %H: %M: %S %p"),
                    'numLinkPoints': newPoint.linkCount(linkType),
                    'newLinkPoint':newLinkPointHTML
                }
            resultJSON = json.dumps(jsonOutput)
            self.response.headers.add_header('content-type', 'application/json', charset='utf-8')
            self.response.out.write(resultJSON)
        else:
            self.response.out.write('Need to be logged in')
开发者ID:aaronlifshin,项目名称:howtosavedemocaracy,代码行数:56,代码来源:addsupportingpoint.py

示例6: post

    def post(self):
        self.response.headers["Content-Type"] = "application/json; charset=utf-8"
        resultJSON = json.dumps({"result": False})
        supportingPoint, supportingPointRoot = Point.getCurrentByUrl(self.request.get("supportingPointURL"))
        oldPoint, oldPointRoot = Point.getCurrentByUrl(self.request.get("parentPointURL"))
        user = self.current_user
        linkType = self.request.get("linkType")

        if user:
            try:
                # This code is if the vote existed before and the point was unlinked, and now
                # it is being re-linked
                voteCount, rating, myVote = RelevanceVote.getExistingVoteNumbers(
                    oldPointRoot.key, supportingPointRoot.key, linkType, user
                )
                supportingPoint._relevanceVote = myVote
                linkType = self.request.get("linkType")
                newLink = [
                    {
                        "pointRoot": supportingPointRoot,
                        "pointCurrentVersion": supportingPoint,
                        "linkType": linkType,
                        "voteCount": voteCount,
                        "fRating": rating,
                    }
                ]
                newVersion = oldPoint.update(pointsToLink=newLink, user=user)
                user.addRelevanceVote(oldPointRoot.key.urlsafe(), supportingPointRoot.key.urlsafe(), linkType, 100)

                # get my vote for this point, to render it in the linkPoint template
                supportingPoint.addVote(user)
            except WhysaurusException as e:
                resultJSON = json.dumps({"result": False, "error": e.message})
            else:
                if newVersion:
                    newLinkPointHTML = self.template_render(
                        "linkPoint.html", {"point": supportingPoint, "linkType": linkType}
                    )
                    resultJSON = json.dumps(
                        {
                            "result": True,
                            "numLinkPoints": newVersion.linkCount(linkType),
                            "newLinkPoint": newLinkPointHTML,
                            "authorURL": self.current_user.url,
                            "author": newVersion.authorName,
                            "dateEdited": newVersion.PSTdateEdited.strftime("%b. %d, %Y, %I:%M %p"),
                        }
                    )
                else:
                    json.dumps({"result": False, "error": "There was a problem updating the point."})
        else:
            resultJSON = json.dumps({"result": "User not logged in. ACCESS DENIED!"})
        self.response.out.write(resultJSON)
开发者ID:aaronlifshin,项目名称:whysaurus,代码行数:53,代码来源:linkpoint.py

示例7: get

 def get(self):
     query = Point.query()
     i = 0
     for point in query.iter():
         if point.supportingPoints:
             for pointKey in point.supportingPoints:
                 point.supportingPointsRoots.append(pointKey)
             point.supportingPoints = []
             for rootKey in point.supportingPointsRoots:
                 root = rootKey.get()
                 if root:
                     pointVer = root.getCurrent()
                     point.supportingPointsLastChange.append(pointVer.key)
                 else:   
                     logging.info('ROOTKEY %s WAS NOT FOUND' % rootKey)              
         else:
             point.supportingPointsRoots = []
             point.supportingPointsLastChange = []
         point.put()
         logging.info('Updating %s' % point.title)
         i = i + 1 
        
     template_values = {
         'message': "Edits made: %d" % i
     }
     path = os.path.join(os.path.dirname(__file__), '../templates/message.html')
     self.response.out.write(template.render(path, template_values))
开发者ID:aaronlifshin,项目名称:howtosavedemocaracy,代码行数:27,代码来源:updateSupportingPointsSchema.py

示例8: post

    def post(self):
        user = self.current_user
        resultJSON = json.dumps({'result': False, 'error': 'Not authorized'})
        if user:
            if not self.request.get('title'):                
                resultJSON = json.dumps({'result': False, 'error': 'Your point must have a title'})
            else:
                sourcesURLs=json.loads(self.request.get('sourcesURLs')) if self.request.get('sourcesURLs') else None
                sourcesNames=json.loads(self.request.get('sourcesNames')) if self.request.get('sourcesNames') else None
                newPoint, newPointRoot = Point.create(
                    title=self.request.get('title'),
                    nodetype=self.request.get('nodetype'),                 
                    content=self.request.get('content'),
                    summaryText=self.request.get('plainText'),
                    user=user,
                    imageURL=self.request.get('imageURL'),
                    imageAuthor=self.request.get('imageAuthor'),
                    imageDescription=self.request.get('imageDescription'),
                    sourceURLs=sourcesURLs,
                    sourceNames=sourcesNames)
                if newPoint:
                    resultJSON = json.dumps({'result': True, 
                                     'pointURL': newPoint.url,
                                     'rootKey': newPointRoot.key.urlsafe()})
                else:
                    resultJSON = json.dumps({'result': False, 'error': 'Failed to create point.'})
        else:
            resultJSON = json.dumps({'result': False, 'error': 'You appear not to be logged in.'})

        self.response.headers.add_header('content-type', 'application/json', charset='utf-8')
        self.response.out.write(resultJSON)
开发者ID:aaronlifshin,项目名称:howtosavedemocaracy,代码行数:31,代码来源:newpoint.py

示例9: post

 def post(self):
     resultJSON = json.dumps({'result': False})
     searchResultsFuture = Point.search(
         searchTerms=self.request.get('searchTerms'), 
         user=self.current_user,
         excludeURL=self.request.get('exclude'), 
         linkType=self.request.get('linkType') 
     )
     searchResults = None
     if searchResultsFuture:
         searchResults = searchResultsFuture.get_result()
         
     template_values = {
         'points': searchResults,
         'linkType': self.request.get('linkType'),
     }
     resultsHTML = self.template_render('pointBoxList.html', template_values)
     
     if searchResults:
         resultJSON = json.dumps({
             'result': True,
             'resultsHTML': resultsHTML,
             'searchString': self.request.get('searchTerms')
         })
     self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
     self.response.out.write(resultJSON)
开发者ID:aaronlifshin,项目名称:whysaurus,代码行数:26,代码来源:ajaxsearch.py

示例10: checkNamespace

 def checkNamespace(self, areaName): 
     bigMessage = []
     noErrors = 0
     pointCount = 0
     bigMessage.append("ooooooooooooooooooooooooooooooooooooooooooooooooooo")
     bigMessage.append("          NAMESPACE: " + areaName)
     bigMessage.append("ooooooooooooooooooooooooooooooooooooooooooooooooooo")
     
     namespace_manager.set_namespace(areaName) 
     
     # Take every point version
     query = Point.query()
     for point in query.iter():
         foundError, newMessages = self.checkPoint(point)   
         bigMessage = bigMessage + newMessages      
         if not foundError:
             noErrors = noErrors + 1
         pointCount = pointCount + 1
         
     bigMessage.append( "%d points checked. No errors detected in %d points" % (pointCount, noErrors))
     
     noErrors = 0
     rootCount = 0
     query = PointRoot.query()
     for pointRoot in query.iter():
         foundError, newMessages = self.checkRoot(pointRoot)
         bigMessage = bigMessage + newMessages
                   
         if not foundError:
             noErrors = noErrors + 1
         rootCount = rootCount + 1
         
     bigMessage.append( "%d roots checked. No errors detected in %d roots" % (rootCount, noErrors))        
     return bigMessage
开发者ID:,项目名称:,代码行数:34,代码来源:

示例11: relevanceVote

 def relevanceVote(self):
     resultJSON = json.dumps({'result': False})
     parentRootURLsafe = self.request.get('parentRootURLsafe')
     childRootURLsafe = self.request.get('childRootURLsafe')
     linkType = self.request.get('linkType')
     vote = self.request.get('vote')        
     user = self.current_user
     
     if int(vote) > 100 or int(vote) < 0:
         resultJSON = json.dumps({'result': False, 'error':'Vote value out of range.'})
         
     # logging.info('ABOUT TO CHECK ALL THE DATA 1:%s 2:%s 3:%s 4:%s ' % (parentRootURLsafe,childRootURLsafe,linkType, vote))
     elif parentRootURLsafe and childRootURLsafe and linkType and user:
         result, newRelevance, newVoteCount = user.addRelevanceVote(
             parentRootURLsafe, childRootURLsafe, linkType, int(vote))
         if result:
             # Hacky, parent score retrieval could be pushed into addRelevanceVote
             parentNewScore = None
             parentPoint, parentPointRoot = Point.getCurrentByRootKey(parentRootURLsafe)
             if parentPoint:
                 parentNewScore = parentPoint.pointValue()
             else:
                 parentNewScore = -999
             resultJSON = json.dumps({
                 'result': True, 
                 'newVote': vote,
                 'newRelevance': str(newRelevance) + '%',
                 'newVoteCount': newVoteCount,
                 'parentNewScore': parentNewScore
             })
     self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
     self.response.out.write(resultJSON)       
开发者ID:aaronlifshin,项目名称:whysaurus,代码行数:32,代码来源:vote.py

示例12: post

 def post(self):
     jsonOutput = {'result': False}
     user = self.current_user
     titles = json.loads(self.request.get('titles'))
     levels = json.loads(self.request.get('levels'))
     dataRefs = json.loads(self.request.get('dataRefs'))
     furtherInfos = json.loads(self.request.get('furtherInfos'))
     sources = json.loads(self.request.get('sources'))
     pointsData = processTreeArrays(titles, levels, dataRefs, furtherInfos, sources)
     
     if user:
         try:
             newMainPoint, newMainPointRoot = Point.createTree(pointsData, user)
         except WhysaurusException as e:
             jsonOutput = {
                 'result': False,
                 'err': str(e)
             }
         else:
             jsonOutput = {
                 'result': True,
                 'url': newMainPoint.url,
                 'rootKey': newMainPointRoot.key.urlsafe()
             }
         resultJSON = json.dumps(jsonOutput)
         logging.info('Tree %s' % resultJSON)
     else:
         resultJSON = json.dumps({'result': False, 'error': 'You appear not to be logged in.'})
     self.response.headers.add_header('content-type', 'application/json', charset='utf-8')
     self.response.out.write(resultJSON)
开发者ID:aaronlifshin,项目名称:howtosavedemocaracy,代码行数:30,代码来源:addtree.py

示例13: checkDBPoint

 def checkDBPoint(self, pointURL):
     point, pointRoot = Point.getCurrentByUrl(pointURL)
     
     if point:
         isError1, messages1 = self.checkPointNew(point)
         
     if pointRoot:
         isError2, messages2 = self.checkRoot(pointRoot)
     
     if not isError1 and not isError2:
         message = 'No errors were found.'
     else:
         messages = []
         if messages1:
             messages += messages1
         if messages2:
             messages += messages2
         if messages == []:
             messages = ['Errors generated, but no messages generated.']
         
     template_values = {
         'messages': messages,            
         'user': self.current_user,
         'currentArea':self.session.get('currentArea')
     }
     self.response.out.write(self.template_render('message.html', template_values))        
开发者ID:,项目名称:,代码行数:26,代码来源:

示例14: post

    def post(self):

        resultJSON = json.dumps({'result': False})
        
        if self.current_user:
            if self.current_user.isLimited:
              resultJSON = json.dumps({'result': False, 'error': 'This account cannot unlink points.'})              
            elif self.request.get('mainPointURL'):
                mainPoint, pointRoot = Point.getCurrentByUrl(self.request.get('mainPointURL'))
                if self.request.get('supportingPointURL'):
                    supportingPointURL = self.request.get('supportingPointURL')
                    newVersion = mainPoint.unlink(self.request.get('supportingPointURL'), 
                                                  self.request.get('linkType'), 
                                                  self.current_user)
                    if newVersion:
                        resultJSON = json.dumps({
                            'result': True, 
                            'pointURL': supportingPointURL,
                            'authorURL': self.current_user.url,
                            'author': newVersion.authorName, 
                            'dateEdited': newVersion.PSTdateEdited.strftime('%b. %d, %Y, %I:%M %p'),
                        })
            else:
               resultJSON = json.dumps({'result': False, 'error': 'URL of main point was not supplied.'})                
        else:
            resultJSON = json.dumps({'result': False, 'error': 'You appear not to be logged in.'})
            
        self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
        self.response.out.write(resultJSON)
开发者ID:aaronlifshin,项目名称:whysaurus,代码行数:29,代码来源:unlinkpoint.py

示例15: checkDBPointRoot

 def checkDBPointRoot(pointRoot):
     logging.info('Checking %s ' % pointRoot.url)
     point, pr = Point.getCurrentByUrl(pointRoot.url)
     isError1 = False
     isError2 = False
     messages1 = []
     messages2 = []
     
     dbc = DBIntegrityCheck()
     if point:
         isError1, messages1 = dbc.checkPoint(point)
         
     if pointRoot:
         isError2, messages2 = dbc.checkRoot(pointRoot)
     
     if not isError1 and not isError2:
         message = 'No errors were found in %s.' % pointRoot.url
         logging.info(message)                      
         
     else:
         message = []
         if messages1:
             message = message + messages1
         if messages2:
             message = message + messages2
         if message == []:
             message = ['Errors generated, but no messages generated.']
         if isError1:
             logging.info(messages1)
         if isError2:
             logging.info(messages2)  
         for m in message:
             logging.info(message)                      
     
     return message
开发者ID:,项目名称:,代码行数:35,代码来源:


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