Exemplo n.º 1
0
def render(template_name,
           extra_vars=None,
           form_fill=None,
           form_errors={},
           method='xhtml'):

    # Pull in extra vars if needed
    globs = extra_vars or {}

    # Second, get the globals
    globs.update(pylons_globals())
    globs['g'] = app_globals
    globs['can'] = can
    globs['_form_errors'] = form_errors

    # Grab a template reference
    template = globs['app_globals'].genshi_loader.load(template_name)

    stream = template.generate(**globs)

    if form_fill is not None:
        filler = HTMLFormFiller(data=form_fill)
        stream = stream | filler

    return literal(stream.render(method=method, encoding=None))
Exemplo n.º 2
0
def render(
    template_name,
    extra_vars=None,
    form_fill=None,
    form_errors={},
    cache_expire=3600,
    cache_private=False,
    method="xhtml",
):

    _setup_cache(cache_expire, cache_private)

    # Pull in extra vars if needed
    globs = extra_vars or {}

    # Second, get the globals
    globs.update(pylons_globals())
    globs["g"] = app_globals
    globs["_form_errors"] = form_errors

    # Grab a template reference
    template = globs["app_globals"].genshi_loader.load(template_name)

    stream = template.generate(**globs)

    if form_fill is not None:
        filler = HTMLFormFiller(data=form_fill)
        stream = stream | filler

    for item in PluginImplementations(IGenshiStreamFilter):
        stream = item.filter(stream)

    return literal(stream.render(method=method, encoding=None))
Exemplo n.º 3
0
def render(template_name,
           extra_vars=None,
           form_fill=None, form_errors={},
           suppress_cache=True,
           method='xhtml'):

    if suppress_cache:
        response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
        response.headers['Pragma'] = 'no-cache'
        response.headers['Expires'] = '0'

    # Pull in extra vars if needed
    globs = extra_vars or {}

    # Second, get the globals
    globs.update(pylons_globals())
    globs['g'] = app_globals
    globs['can'] = can
    globs['_form_errors'] = form_errors

    # Grab a template reference
    template = globs['app_globals'].genshi_loader.load(template_name)

    stream = template.generate(**globs)

    if form_fill is not None:
        filler = HTMLFormFiller(data=form_fill)
        stream = stream | filler

    for item in PluginImplementations(IGenshiStreamFilter):
        stream = item.filter(stream)

    return literal(stream.render(method=method, encoding=None))
Exemplo n.º 4
0
def render(template_name, extra_vars=None, form_fill=None, form_errors={}, suppress_cache=True, method="xhtml"):

    if suppress_cache:
        response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
        response.headers["Pragma"] = "no-cache"
        response.headers["Expires"] = "0"

    # Pull in extra vars if needed
    globs = extra_vars or {}

    # Second, get the globals
    globs.update(pylons_globals())
    globs["g"] = app_globals
    globs["can"] = can
    globs["_form_errors"] = form_errors

    # Grab a template reference
    template = globs["app_globals"].genshi_loader.load(template_name)

    stream = template.generate(**globs)

    if form_fill is not None:
        filler = HTMLFormFiller(data=form_fill)
        stream = stream | filler

    return literal(stream.render(method=method, encoding=None))
Exemplo n.º 5
0
def render(template_name,
           extra_vars=None,
           form_fill=None,
           form_errors={},
           cache_expire=3600,
           cache_private=False,
           method='xhtml'):

    _setup_cache(cache_expire, cache_private)

    # Pull in extra vars if needed
    globs = extra_vars or {}

    # Second, get the globals
    globs.update(pylons_globals())
    globs['g'] = app_globals
    globs['can'] = can
    globs['_form_errors'] = form_errors

    # Grab a template reference
    template = globs['app_globals'].genshi_loader.load(template_name)

    stream = template.generate(**globs)

    if form_fill is not None:
        filler = HTMLFormFiller(data=form_fill)
        stream = stream | filler

    for item in PluginImplementations(IGenshiStreamFilter):
        stream = item.filter(stream)

    return literal(stream.render(method=method, encoding=None))
Exemplo n.º 6
0
    def render_template():
        # Pull in extra vars if needed
        globs = extra_vars or {}

        # Second, get the globals
        globs.update(pylons_globals())
        globs['g'] = app_globals
        globs['_form_errors'] = form_errors

        # Grab a template reference
        template = globs['app_globals'].genshi_loader.load(template_name)
        stream = template.generate(**globs)
        if form_fill is not None:
            filler = HTMLFormFiller(data=form_fill)
            stream = stream | filler

        return literal(stream.render(method=method, encoding=None))