• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python point.Point类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了Point类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:


示例16: post

 def post(self):
     resultJSON = json.dumps({'result': False})
     point, pointRoot = Point.getCurrentByUrl(self.request.get('pointURL'))
     user = self.current_user
     if point and user:
         if user.addVote(point, int(self.request.get('vote'))):
             resultJSON = json.dumps({'result': True, 'newVote': self.request.get('vote')})
     self.response.headers.add_header('content-type', 'application/json', charset='utf-8')
     self.response.out.write(resultJSON)
开发者ID:aaronlifshin,项目名称:howtosavedemocaracy,代码行数:9,代码来源:vote.py


示例17: indClearLowQualityFlags

def indClearLowQualityFlags(cursor=None, num_updated=0, batch_size=250, cntUpdatedNet=0, namespace=None, namespaces=None):
    logging.info('ClearLowQuality Update: Start: %d  Batch: %d  Namespace: %s' % (num_updated, batch_size, namespace))

    if namespace:
        previous_namespace = namespace_manager.get_namespace()
        namespace_manager.set_namespace(namespace)
    else:
        previous_namespace = None

    try:
        query = Point.query()
        points, next_cursor, more = query.fetch_page(batch_size, start_cursor=cursor)

        cnt = 0
        cntSkip = 0
        cntUpdate = 0
        # for p in query.iter():
        for p in points:
            cnt += 1

            # if p.isLowQualityAdmin == False:
            #     cntSkip += 1
            #     continue
            if p.isLowQualityAdmin:
                cntUpdate += 1
            p.isLowQualityAdmin = False
            p.put()

        logging.info('ClearLowQuality Incremental: Count: %d  Updated: %d  Skipped: %d' % (cnt, cntUpdate, cntSkip))
    finally:
        if previous_namespace:
            namespace_manager.set_namespace(previous_namespace)

    # If there are more entities, re-queue this task for the next page.
    if more:
        deferred.defer(indClearLowQualityFlags,
                       cursor=next_cursor,
                       num_updated=(num_updated + cnt),
                       batch_size=batch_size,
                       cntUpdatedNet=(cntUpdatedNet + cntUpdate),
                       namespace=namespace,
                       namespaces=namespaces)
    else:
        logging.warning('ClearLowQuality Complete! - Net Updated: %d  Namespace: %s' % (cntUpdatedNet + cntUpdate, namespace))

        if namespaces and len(namespaces) > 0:
            nextNamespace = namespaces[0]
            del namespaces[0]
            logging.warning('ClearLowQuality: Next Namespace: %s  Count: %d' % (nextNamespace, len(namespaces)))
            deferred.defer(indClearLowQualityFlags,
                           cursor=None,
                           num_updated=0,
                           batch_size=batch_size,
                           cntUpdatedNet=0,
                           namespace=nextNamespace,
                           namespaces=namespaces)
开发者ID:aaronlifshin,项目名称:whysaurus,代码行数:56,代码来源:batchJobs.py


示例18: post

 def post(self):
     resultJSON = json.dumps({'result': False})
     point, pointRoot = Point.getCurrentByUrl(self.request.get('pointURL'))
     user = self.current_user
     newRibbonValue = self.request.get('ribbon') == 'true'
     if point and user:
         if user.setRibbon(point, newRibbonValue):
             resultJSON = json.dumps({'result': True, 'ribbonTotal': point.ribbonTotal})
     self.response.headers.add_header('content-type', 'application/json', charset='utf-8')
     self.response.out.write(resultJSON)
开发者ID:aaronlifshin,项目名称:howtosavedemocaracy,代码行数:10,代码来源:setribbon.py


示例19: post

    def post(self):
        user = self.current_user
        if user:

            resultJSON = json.dumps({"result": False})
            oldPoint, oldPointRoot = Point.getCurrentByUrl(self.request.get("urlToEdit"))
            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
            sourcesToRemove = (
                json.loads(self.request.get("sourcesToRemove")) if self.request.get("sourcesToRemove") else None
            )
            if oldPoint == None:
                resultJSON = json.dumps(
                    {"result": False, "error": "Unable to edit point. Please refresh the page and try again."}
                )
            elif user.isLimited:
                resultJSON = json.dumps({"result": False, "error": "This account cannot edit points."})
            else:
                sources = Source.constructFromArrays(sourcesURLs, sourcesNames, oldPoint.key)
                newVersion = oldPoint.update(
                    newTitle=self.request.get("title"),
                    newContent=self.request.get("content"),
                    newSummaryText=self.request.get("plainText"),
                    user=self.current_user,
                    imageURL=self.request.get("imageURL"),
                    imageAuthor=self.request.get("imageAuthor"),
                    imageDescription=self.request.get("imageDescription"),
                    sourcesToAdd=sources,
                    sourceKeysToRemove=sourcesToRemove,
                )
                if newVersion:
                    sources = newVersion.getSources()
                    sourcesHTML = self.template_render("sources.html", {"sources": sources})

                    resultJSON = json.dumps(
                        {
                            "result": True,
                            "version": newVersion.version,
                            "author": newVersion.authorName,
                            "authorURL": self.current_user.url,
                            "dateEdited": newVersion.PSTdateEdited.strftime("%b. %d, %Y, %I:%M %p"),
                            "pointURL": newVersion.url,
                            "imageURL": newVersion.imageURL,
                            "imageAuthor": newVersion.imageAuthor,
                            "imageDescription": newVersion.imageDescription,
                            "sourcesHTML": sourcesHTML,
                        }
                    )
                    ReportEvent.queueEventRecord(user.key.urlsafe(), newVersion.key.urlsafe(), None, "Edit Point")
                else:
                    # This is the only way newVersion will fail
                    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,代码行数:55,代码来源:editpoint.py


示例20: post

 def post(self):
     resultJSON = json.dumps({'result': False})
     point, pointRoot = Point.getCurrentByUrl(self.request.get('pointURL'))
     parentPointURL = self.request.get('parentPointURL')
     parentPoint = None
     if parentPointURL:
         parentPoint, parentPointRoot = Point.getCurrentByUrl(parentPointURL)
     user = self.current_user
     if point and user:
         if user.addVote(point, int(self.request.get('vote'))):
             point.updateBacklinkedSorts(pointRoot)
             parentNewScore = None
             if parentPoint:
                 parentNewScore = parentPoint.pointValue()
             resultJSON = json.dumps({'result': True,
                                      'newVote': self.request.get('vote'),
                                      'newScore': point.pointValue(),
                                      'parentNewScore': parentNewScore})
     self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
     self.response.out.write(resultJSON)
开发者ID:aaronlifshin,项目名称:whysaurus,代码行数:20,代码来源:vote.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python post.Post类代码示例发布时间:2022-05-27
下一篇:
Python package_version.PackageVersion类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap