def changeUserBag(userID, newBagStatus, lensID): if newBagStatus in ['wantIt', 'haveIt', 'doNotWant', 'clearStatus']: bagInstance = getBagInstance(userID, lensID) if bagInstance is not None: bagInstance.bagStatus = newBagStatus else: bagInstance = userLensBag( userID = userID, bagStatus = newBagStatus, lensID = lensID) bagInstance.put() cacheKey = userBagCacheKey(userID, lensID) #get the individual lens bag key memcache.set(cacheKey, bagInstance) updateUserBag(userID) getBagInstance(userID, lensID, update = True) getLensStats(lensID, update = True) getTotalLensInstances(refresh = True)
def setUserUses(userID, lensID, newUses): #newUses is a list useString = '' for use in newUses: useString += use + '|' bagInstance = getBagInstance(userID, lensID) if bagInstance is None: bagInstance = userLensBag( userID = userID, bagStatus = 'clearStatus', lensID = lensID, lensUses = useString) bagInstance.put() else: bagInstance.lensUses = useString bagInstance.put() getBagInstance(userID, lensID, update = True) getLensUses(lensID, update = True) getAllUses(update = True)