Exemplo n.º 1
0
def render_cheetah_file(resource, data):
    paths = cherrypy.request.app.root.paths
    filename = paths.get_template_path(resource)
    try:
        params = {}
        lang = validate_language(get_lang())
        gettext_conf = {'domain': cherrypy.request.app.root.domain,
                        'localedir': paths.mo_dir,
                        'lang': [lang]}
        params['lang'] = gettext_conf
        params['data'] = data
        return Template(file=filename, searchList=params).respond()
    except OSError, e:
        if e.errno == errno.ENOENT:
            raise cherrypy.HTTPError(404)
        else:
            raise
Exemplo n.º 2
0
def render_cheetah_file(resource, data):
    paths = cherrypy.request.app.root.paths
    domain = cherrypy.request.app.root.domain
    filename = paths.get_template_path(resource)
    try:
        params = {}
        lang = validate_language(get_lang(), domain)
        gettext_conf = {'domain': domain,
                        'localedir': paths.mo_dir,
                        'lang': [lang]}
        params['lang'] = gettext_conf
        params['data'] = data
        return Template(file=filename, searchList=params).respond()
    except OSError, e:
        if e.errno == errno.ENOENT:
            raise cherrypy.HTTPError(404)
        else:
            raise