def api_comments(*, page='1'): page_index = get_page_index(page) num = yield from Comment.findNumber('count(id)') p = Page(num, page_index) if num == 0: return dict(page=p, comments=()) comments = yield from Comment.findAll(orderBy='created_at desc', limit=(p.offset, p.limit)) return dict(page=p, comments=comments)
def get_blog(id): blog = yield from Blogs.find('id=?',[id]) comments = yield from Comment.findAll('blog_id=?',[id],orderby='created_at DESC') return { '__template__':'blog.html', 'blog':blog, 'comments':comments }
def api_comments(*,page='1'): page_index = get_page_index(page) num = yield from Comment.findNumber('count(id)') p = Page(num,page_index) if num == 0 : return dict(page=p,comments = ()) comments = yield from Comment.findAll(orderBy='created_at desc',limit=(p.offset,p.limit)) return dict(page=p,comments=comments)
def get_blog(id): blog = yield from Blog.find(id) comments = yield from Comment.findAll('blog_id=?', [id], orderBy='created_at desc') for c in comments: c.html_content = text2html(c.content) blog.html_content = markdown2.markdown(blog.content) return {'__template__': 'blog.html', 'blog': blog, 'comments': comments}
def get_blog(id): blog = yield from Blog.find(id) comments = yield from Comment.findAll('blog_id=?', [id], orderBy='created_at desc') for c in comments: c.html_content = text2html(c.content) blog.html_content = markdown2.markdown(blog.content) return { '__template__': 'blog.html', 'blog': blog, 'comments': comments }