Ejemplo n.º 1
0
def newComment(lensID, comment, user, reviewLink = None):
	if reviewLink is None or reviewLink == '':
		reviewDisplay = 'none'
	else:
		reviewDisplay = 'visible'

	if comment is None or comment == '':
		comment = 'blank_comment'

	commentObject = lensComments.all().filter('lensID =', lensID).filter('userID = ', user.id).get()
	if commentObject is None:
		commentObject = lensComments(
			lensID = lensID,
			comment = comment,
			reviewLink = reviewLink,
			reviewDisplay = reviewDisplay,
			userID = user.id,
			count = 0)
		commentObject.put()
	else:
		if comment == 'blank_comment':
			commentObject.delete()			
		else:		
			commentObject.comment = comment
			commentObject.reviewLink =reviewLink
			commentObject.reviewDisplay = reviewDisplay
			commentObject.put()	
	memcache.delete('commentsFor' + lensID)
	getAllUserComments(user.id, forceRefresh = True)
Ejemplo n.º 2
0
def getAllUserComments(userID, forceRefresh = False):
	userComments = memcache.get('commentsBy' + userID)
	if userComments is None or forceRefresh:
		userComments = lensComments.all().filter('userID = ', userID)
		memcache.set('commentsBy' + userID, userComments)
	return userComments
Ejemplo n.º 3
0
def getComments(lensID):
	commentObject = memcache.get('commentsFor' + lensID)
	if commentObject is None:
		commentObject = lensComments.all().filter('lensID = ', lensID)
		memcache.set('commentsFor' + lensID, commentObject)
	return commentObject