Esempio n. 1
0
def fetch_reviews(start, end):
    result = []
    revquery = Review.gql("WHERE modified >= :1 AND modified < :2", 
                          dt2ISO(start), dt2ISO(end))
    #if this max is exceeded, subdivide blocks, and/or filter types, and/or...
    reviews = revquery.fetch(1000, read_policy=db.EVENTUAL_CONSISTENCY, 
                             deadline = 10)
    for review in reviews:
        if (not (review.svcdata and 
                 batch_flag_attrval(review) in review.svcdata)):
            result.append(str(review.key().id()))
    return result
Esempio n. 2
0
def fetch_blog_reviews(pen):
    # retrieve the review data, not filtering out batch updates
    dold = dt2ISO(datetime.datetime.utcnow() - datetime.timedelta(365*2))
    # Same index retrieval already used by rev.py SearchReviews
    where = "WHERE penid = :1 AND modified >= :2 AND modified <= :3" +\
        " ORDER BY modified DESC"
    ckey = "blog" + pen.name_c
    revquery = Review.gql(where, pen.key().id(), dold, nowISO())
    # Return just enough results for an RSS feed to note updates, but
    # not so many that it takes any significant time to retrieve,
    # cache and return the results.  Client requests more to fill.
    qres = cached_query(ckey, revquery, "", 20, Review, True)
    return qres;
Esempio n. 3
0
 def post(self):
     rc = ReviewComment(revid = intz(self.request.get('revid')))
     review = cached_get(rc.revid, Review)
     if not review:
         self.error(404)
         self.response.out.write("Review " + str(rc.revid) + " not found")
         return
     rc.revpenid = review.penid
     rc.cmtpenid = intz(self.request.get('cmtpenid'))
     rc.rctype = self.request.get('rctype')
     if rc.rctype == "question":
         if not is_following(rc.cmtpenid, rc.revpenid):
             self.error(400)
             self.response.out.write("Must be following to question")
             return
         if not is_following(rc.revpenid, rc.cmtpenid):
             self.error(400)
             self.response.out.write("Must be following back to question")
             return
     elif rc.rctype == "comment":
         # query matches rev.py GetReviewByKey. No new indexes...
         where = "WHERE penid = :1 AND revtype = :2 AND cankey = :3" +\
             " ORDER BY modified DESC"
         revq = Review.gql(where, rc.cmtpenid, review.revtype, review.cankey)
         revs = revq.fetch(5, read_policy=db.EVENTUAL_CONSISTENCY, 
                           deadline=10)
         if len(revs) == 0:
             self.error(400)
             self.response.out.write(
                 "You must have a corresponding review to comment")
             return
     else:
         self.error(400)
         self.response.out.write("rctype must be question or comment")
         return
     if have_pending_comment(rc):
         self.error(400)
         self.response.out.write("New " + rc.rctype + 
                                 " not allowed while previous " + 
                                 rcs[0].rctype + " still pending")
         return
     rc.rcstat = "pending"
     rc.comment = self.request.get('comment')
     if len(rc.comment.strip()) == 0:
         self.error(400)
         self.response.out.write("No text sent")
         return
     rc.resp = ""
     rc.modified = nowISO()
     rc.put()  #nocache
     returnJSON(self.response, [ rc ])