def get_recent_posts(self): posts = {} postdb = PostsDB.all().order("-rating").fetch(30) l = [] for post in postdb: l.append((post.key().id(), post.title, post.author, post.subject, post.date, post.like_count, post.comment_count, post.tag1, post.tag2, post.tag3, post.like, post.dislike)) return l
def get_recent_posts(self): l = [] postdb = PostsDB.all().fetch(100) for post in postdb: date = self.get_date_without_decimal_in_seconds(post.date) l.append((post.key().id(), post.title, post.author, post.subject, date, post.like_count, post.comment_count, post.tag1, post.tag2, post.tag3, post.like, post.dislike)) return l
def loadHelloUserDb(self, userdb, update = False): key = 'hellouserkey' hellouserdb = memcache.get(key) if not hellouserdb or update: hellouserdb = PostsDB.all().filter('userdb =',userdb).fetch(30) memcache.set(key, hellouserdb) hellouserdb = list(hellouserdb) return hellouserdb
def loadTrendingPostsDb(self, filter = "", order = "", update = False): key = 'trendingkey' postsdb = memcache.get(key) if not postsdb or update: postsdb = PostsDB.all().order(order).fetch(30) memcache.set(key,postsdb) postsdb = list(postsdb) return postsdb
def loadRecentPostsDb(self, filter = "", order = "", update = False): # print 'hi' Seems working but the statement 'db fetch' was never printed. But 'hi' got printed. key = 'recentkey' postsdb = memcache.get(key) if not postsdb or update: postsdb = PostsDB.all().order('-date').fetch(30) memcache.set(key,postsdb) postsdb = list(postsdb) return postsdb
def get_tagged_posts(self,tagname): l = [] postdb = PostsDB.all().filter('tag1 =',tagname).fetch(100) for post in postdb: date = self.get_date_without_decimal_in_seconds(post.date) l.append((post.key().id(), post.title, post.author, post.subject, date, post.like_count, post.comment_count, post.tag1, post.tag2, post.tag3, post.like, post.dislike,post.post)) postdb = PostsDB.all().filter('tag2 =',tagname).fetch(100) for post in postdb: date = self.get_date_without_decimal_in_seconds(post.date) l.append((post.key().id(), post.title, post.author, post.subject, date, post.like_count, post.comment_count, post.tag1, post.tag2, post.tag3, post.like, post.dislike,post.post)) postdb = PostsDB.all().filter('tag3 =',tagname).fetch(100) for post in postdb: date = self.get_date_without_decimal_in_seconds(post.date) l.append((post.key().id(), post.title, post.author, post.subject, date, post.like_count, post.comment_count, post.tag1, post.tag2, post.tag3, post.like, post.dislike,post.post)) return set(l)
def get(self,username): """The homepage of username is hidden from non-logged in user. This may prompt him to register for the site.""" username_ck = str(self.request.cookies.get('username_ck')) if not username_ck or username_ck == 'None': self.redirect('/login') else: username_sec = self.encrypt_username(username) userdb = UserDB.all().filter('username ='******'userdb =',i).fetch(100) for post in posts: date = self.get_date_without_decimal_in_seconds(post.date) l.append((post.key().id(), post.title, post.author, post.subject, date, post.like_count, post.comment_count, post.tag1, post.tag2, post.tag3, post.like, post.dislike)) user_posts = l whos_page = username username = self.return_username_if_valid_cookie(username_ck) q = PeopleDB.all().filter('people_follows =',username_ck).fetch(100) following = [] for i in q: following.append(i.people_followed) if whos_page != username: if whos_page in following: follow = "" else: follow = "follow" following = "" else: follow = "" self.pass_template_value_hellouser_page(logout = 'Logout',image_id_key = image_key, username = username ,whos_page = whos_page, follow = follow, posts = user_posts, following = following)