def getFeedData(self, feedUrl, count): keyName = str(hash(feedUrl) * hash(feedUrl)) + '_' + str(count) feedDataSettings = GetFeedDataSettings(feedUrl) if feedDataSettings is None: logging.debug( 'getFeedData => feedDataSettings is None. Why?!? %s keyName', feedUrl, keyName) else: if count == '-1': feedData = feedDataSettings.private_data priorData = feedDataSettings.feedDataCount else: fd = FeedData.get_by_id(keyName) if fd is None: logging.debug('getFeedData => fd is None. Why?!?') # ' %s keyName, feedUrl: ', keyName, feedUrl) feedData = '' else: feedData = fd.private_data priorData = int(count) - 1 if count == '-1': count = -2 return feedData, keyName, priorData, feedDataSettings.article_count
def get(self): self.response.headers['Content-Type'] = 'application/json' self.response.headers['Cache-Control'] = "private, max-age=0" user = users.get_current_user() if user: ud = GetAppUserByEmail(user.email()) if ud is not None: allUserRead = FeedData.query( ReadData.app_username == ud.app_username).fetch() ##data = [{'url': read.feedUrl, 'readCount': read.readCount} for read in allUserRead] data = [{read.feedUrl: read.readCount} for read in allUserRead] self.response.out.write(str(json.dumps(data)))
def findArticles(self, feedUrl, feedDataSettings): feedDataCount = 1 articlesToMarkAsRead = self.findArticlesFromFeedData( feedDataSettings.private_data) while (feedDataCount <= feedDataSettings.feedDataCount): id = str(hash(feedUrl) * hash(feedUrl)) + '_' + str(feedDataCount) # memory hog otherwise!!! fd = FeedData.get_by_id(id, use_cache=False, use_memcache=False) if fd.private_data is not None and fd.private_data != '': articlesToMarkAsRead = articlesToMarkAsRead + \ self.findArticlesFromFeedData(fd.private_data) feedDataCount = feedDataCount + 1 return articlesToMarkAsRead