def getObjectLikes(likeKey): totalLikes = memcache.get('likesFor' + likeKey) if totalLikes is None: likeQuery = likes.all().filter('objectID = ', likeKey) totalLikes = 0 for like in likeQuery: totalLikes += 1 memcache.set('likesFor' + likeKey, totalLikes) return totalLikes
def getUserLikeHistory(localUser): if localUser.exists: likeHistory = memcache.get('likeHistoryFor' + localUser.id) if likeHistory is None: allLikes = likes.all().filter('userID =', localUser.id) likeHistory = [] for like in allLikes: likeHistory.append(like) memcache.set('likeHistoryFor' + localUser.id, likeHistory) else: likeHistory = [] return likeHistory
def undoLike(likeKey, localUser, ownerID): oldLike = likes.all().filter('objectID = ', likeKey).filter('userID =',localUser.id).get() oldLike.delete() updateUserRating(ownerID, -1) memcache.delete('likesFor' + likeKey) memcache.delete('likeHistoryFor' + localUser.id)