def _get_posts(cursor, limit, condition=None): if condition: posts, next_cursor, more = Post.query(eval(condition)).order( -Post.date ).fetch_page(limit, start_cursor=cursor) else: posts, next_cursor, more = Post.query().order( -Post.date ).fetch_page(limit, start_cursor=cursor) return posts, next_cursor, more
def _do_older_pagination(request, cursor, limit): if (request.get('prev_go') == 'newer'): cursor = cursor.reversed() query = Post.query().order( -Post.date ) posts, next_cursor, more = query.fetch_page(int(request.get('numEls')), start_cursor=cursor) if (request.get('prev_go') == 'newer'): posts, next_cursor, more = query.fetch_page(limit, start_cursor=next_cursor) return posts, next_cursor, more
def _do_newer_pagination(request, cursor, limit): if (request.get('prev_go') == 'older'): cursor = cursor.reversed() query = Post.query().order( Post.date ) posts, next_cursor, more = query.fetch_page(int(request.get('numEls')), start_cursor=cursor) if (request.get('prev_go') == 'older'): posts, next_cursor, more = query.fetch_page(limit, start_cursor=next_cursor) ''' posts es devuelto como una lista inversa ''' return posts[::-1], next_cursor, more
def get_posts_in(urlsafe_chatroom_id): chatroom = get_chatroom(urlsafe_chatroom_id) return Post.query(Post.chatroom_key == chatroom.key).fetch()
def _get_posts_with_condition(cursor, limit, condition): return Post.query(condition).order( -Post.date ).fetch_page(limit, start_cursor=cursor)