Example #1
0
def layout_processor(handler):
    """Processor to wrap the output in site template."""
    out = handler()
    
    path = web.ctx.path[1:]
    
    if out is None:
        out = RawText("")
    
    if isinstance(out, basestring):
        out = web.template.TemplateResult(__body__=out)
     
    if 'title' not in out:
        out.title = path

    # overwrite the content_type of content_type is specified in the template
    if 'content_type' in out:
        web.ctx.headers = [h for h in web.ctx.headers if h[0].lower() != 'content-type']
        web.header('Content-Type', out.content_type)
        
    if hasattr(out, 'rawtext'):
        html = out.rawtext
    else:
        html = view.render_site(config.site, out)
        
    # cleanup references to avoid memory leaks
    web.ctx.site._cache.clear()
    web.ctx.pop('site', None)
    web.ctx.env = {}
    context.clear()

    return html
Example #2
0
def layout_processor(handler):
    """Processor to wrap the output in site template."""
    out = handler()

    path = web.ctx.path[1:]

    if out is None:
        out = RawText("")

    if isinstance(out, basestring):
        out = web.template.TemplateResult(__body__=out)

    if 'title' not in out:
        out.title = path

    # overwrite the content_type of content_type is specified in the template
    if 'content_type' in out:
        web.ctx.headers = [
            h for h in web.ctx.headers if h[0].lower() != 'content-type'
        ]
        web.header('Content-Type', out.content_type)

    if hasattr(out, 'rawtext'):
        html = out.rawtext
    else:
        html = render_site(config.site, out)

    # cleanup references to avoid memory leaks
    web.ctx.site._cache.clear()
    web.ctx.pop('site', None)
    web.ctx.env = {}
    context.clear()

    return html
Example #3
0
def notfound(path=None, create=True):
    path = path or web.ctx.path
    html = template.render_template("notfound", path, create=create)
    return web.notfound(render_site(config.site, html))
Example #4
0
def notfound(path = None, create = True):
    path = path or web.ctx.path
    html = template.render_template("notfound", path, create = create)
    return web.notfound(render_site(config.site, html))