Пример #1
0
def single_post(view):
    def title_text(title):
        def flat_nodes(nodes):
            r = []
            for n in nodes:
                if n.nodeType == n.TEXT_NODE:
                    r.append(n.data)
                else:
                    r.extend(flat_nodes(n.childNodes))
            return r
        import xml.dom.minidom as dom
        return ''.join(flat_nodes(dom.parseString((
                '<title>' + title + '</title>').encode('utf-8')).childNodes))
    try:
        post = base.post_for_client(models.post.by_id(view.request.get('p')))
        view.put_page('templates/post.html', {
            'post': post,
            'title': title_text(post.title),
        })
    except ValueError:
        base.raise_not_found(view)
Пример #2
0
def post_for_client(post, url):
    post = base.post_for_client(post)
    post.ident = ''.join([url.scheme, '://', url.netloc, '/?p=', str(post.pid)])
    return post
Пример #3
0
def post_for_client(post, url):
    post = base.post_for_client(post)
    post.ident = ''.join(
        [url.scheme, '://', url.netloc, '/?p=',
         str(post.pid)])
    return post