コード例 #1
0
 def addRelevanceVote(self, parentRootURLsafe, childRootURLsafe, linkType, vote):
     parentRootKey = ndb.Key(urlsafe=parentRootURLsafe)
     childRootKey = ndb.Key(urlsafe=childRootURLsafe)
     pointRoot = parentRootKey.get()
     curPoint = pointRoot.current.get()
     
     oldRelVote = RelevanceVote.query(
         RelevanceVote.parentPointRootKey == parentRootKey,
         RelevanceVote.childPointRootKey == childRootKey,
         RelevanceVote.linkType == linkType,
         ancestor=self.key).get()
         
     newRelVote = RelevanceVote(
         parent=self.key,
         parentPointRootKey = parentRootKey,
         childPointRootKey = childRootKey,
         value = vote,
         linkType=linkType)
     return self.transactionalAddRelevanceVote(
         curPoint, oldRelVote, newRelVote)
コード例 #2
0
    def getRelevanceVotes_async(self, parentPoint):
        parentRootKey = parentPoint.key.parent();
        maxNumVotes = parentPoint.numSupporting + parentPoint.numCounter;

        rVotes = None
        if maxNumVotes > 0:
            # MULTIPLY numVotes * 2 because the current set of points may be smaller
            # than the set for a given version
            rVotes = yield RelevanceVote.query(
                RelevanceVote.parentPointRootKey == parentRootKey,
                ancestor = self.key).fetch_async(maxNumVotes*2)
        raise ndb.Return(rVotes)
コード例 #3
0
 def getRelevanceVotes_async(self, parentPoint):
     parentRootKey = parentPoint.key.parent();
     maxNumVotes = parentPoint.numSupporting + parentPoint.numCounter;
     
     rVotes = None
     if maxNumVotes > 0:
         # MULTIPLY numVotes * 2 because the current set of points may be smaller
         # than the set for a given version
         rVotes = yield RelevanceVote.query(
             RelevanceVote.parentPointRootKey == parentRootKey, 
             ancestor = self.key).fetch_async(maxNumVotes*2)
     raise ndb.Return(rVotes)
コード例 #4
0
    def addRelevanceVote(self, parentRootURLsafe, childRootURLsafe, linkType, vote):
        parentRootKey = ndb.Key(urlsafe=parentRootURLsafe)
        childRootKey = ndb.Key(urlsafe=childRootURLsafe)
        pointRoot = parentRootKey.get()
        curPoint = pointRoot.current.get()

        oldRelVote = RelevanceVote.query(
            RelevanceVote.parentPointRootKey == parentRootKey,
            RelevanceVote.childPointRootKey == childRootKey,
            RelevanceVote.linkType == linkType,
            ancestor=self.key).get()

        newRelVote = RelevanceVote(
            parent=self.key,
            parentPointRootKey = parentRootKey,
            childPointRootKey = childRootKey,
            value = vote,
            linkType=linkType)
        return self.transactionalAddRelevanceVote(
            curPoint, oldRelVote, newRelVote)