%doc> defines a set of "data listing" methods, which provide a template-oriented interface to various kinds of list-based information. %doc> <%global> from zblog.domain.blog import * %global> <%method bloglist> <%args> loop=True user=None %args> <%init> if user is not None: blogs = Blog.mapper.select_by(owner_id=user.id) else: blogs = Blog.mapper.select() if not m.has_content(): return blogs %init> % if loop: % for b in blogs: <% m.content(blog=b) %> % % else: <% m.content(blogs=blogs) %> % %method> <%method blogurl trim="both"> <%args> blog %args> /blog/<% repr(blog.id) %>/ %method> <%method blogposts> <%args> loop=True blog keyword=False %args> <%init> posts = Post.mapper.select_by(blog_id=blog.id, keyword=keyword) if not m.has_content(): return posts %init> % if loop: % for p in posts: <% m.content(post=p) %> % % else: <% m.content(posts=posts) %> % %method> <%method postcomments> <%args> loop=True post %args> <%init> comments = Comment.find_by_post(post) if not m.has_content(): return comments %init> % if loop: % for c in comments: <% m.content(comment=c) %> % % else: <% m.content(comments=comments) %> % %method>