Exemple #1
0
def by_tag(t, page=0, count=util.ITEMS_PER_PAGE):
    post_ids = [r.post_id for r in db.Query(tag.TagPostR).filter('tag =', t)]
    post_ids = sorted(post_ids, reverse=True)[count * page:count * (page + 1)]
    return [
        post.init_tags(tag.tags_by_post_id(post.pid)).fix_fields()
        for post in db.Query(Post).filter('pid in', post_ids).order('-date')
    ]
Exemple #2
0
 def fetch_posts(start_index, count):
     if count <= 0:
         return []
     return [
         p.init_tags(tag.tags_by_post_id(p.pid))
         for p in db.Query(Post).order('-date').fetch(count,
                                                      offset=start_index)
     ]
Exemple #3
0
def by_id(ident):
    post_id = int(ident)
    posts = db.Query(Post).filter('pid =', post_id)
    if posts.count() == 0:
        raise ValueError('no such post')
    return posts[0].init_tags(tag.tags_by_post_id(post_id)).fix_fields()
Exemple #4
0
def by_id(ident):
    post_id = int(ident)
    posts = db.Query(Post).filter('pid =', post_id)
    if posts.count() == 0:
        raise ValueError('no such post')
    return posts[0].init_tags(tag.tags_by_post_id(post_id))
Exemple #5
0
def by_tag(t, page=0, count=util.ITEMS_PER_PAGE):
    post_ids = [r.post_id for r in db.Query(tag.TagPostR).filter('tag =', t)]
    post_ids = sorted(post_ids, reverse=True)[count * page: count * (page + 1)]
    return [post.init_tags(tag.tags_by_post_id(post.pid)) for post in
                      db.Query(Post).filter('pid in', post_ids).order('-date')]
Exemple #6
0
 def fetch_posts(start_index, count):
     if count <= 0:
         return []
     return [p.init_tags(tag.tags_by_post_id(p.pid)) for p in
                   db.Query(Post).order('-date')
                                 .fetch(count, offset=start_index)]
Exemple #7
0
def _load_cache():
    return [p.init_tags(tag.tags_by_post_id(p.pid))
            for p in db.Query(Post).order('-date').fetch(util.ITEMS_PER_PAGE)]
Exemple #8
0
def fetch(page=0, count=util.ITEMS_PER_PAGE):
    if page == 0:
        return _first_page_posts(count)
    return [post.init_tags(tag.tags_by_post_id(post.pid)) for post in
            db.Query(Post).order('-date').fetch(count, count * page)]
Exemple #9
0
def _load_cache():
    return [p.init_tags(tag.tags_by_post_id(p.pid))
            for p in db.Query(Post).order('-date').fetch(util.ITEMS_PER_PAGE)]
Exemple #10
0
def fetch(page=0, count=util.ITEMS_PER_PAGE):
    if page == 0:
        return _first_page_posts(count)
    return [post.init_tags(tag.tags_by_post_id(post.pid)) for post in
       db.Query(Post).order('-date').fetch(count, count * page)]