view roundup/cgi/engine_chameleon.py @ 4904:3b632a25b1b3

Correctly recreate the database directory during tracker re-initialise The database directory value was being fetched from the tracker config and being appended to the tracker home directory, but the database directory value in the config already has the tracker home prepended which resulted in the database directory being recreated in a nonsensical location. This fix is a bit of a hack, but the relevant code is likely to be removed in v1.6, so it shouldn't be too bad in the short term.
author John Kristensen <john@jerrykan.com>
date Sat, 12 Jul 2014 00:03:05 +1000
parents 0421390b3094
children 56c9bcdea47f
line wrap: on
line source

"""Templating engine adapter for the Chameleon."""

__docformat__ = 'restructuredtext'

import os.path
import chameleon

from roundup.cgi.templating import StringIO, context, TALLoaderBase

class Loader(TALLoaderBase):
    def __init__(self, dir):
        self.dir = dir
        self.loader = chameleon.PageTemplateLoader(dir)

    def load(self, tplname):
        src, filename = self._find(tplname)
        return RoundupPageTemplate(self.loader.load(src))

class RoundupPageTemplate(object):
    def __init__(self, pt):
        self._pt = pt

    def render(self, client, classname, request, **options):
        c = context(client, self, classname, request)
        c.update({'options': options})

        def translate(msgid, domain=None, mapping=None, default=None):
            result = client.translator.translate(domain, msgid,
                         mapping=mapping, default=default)
            return unicode(result, client.translator.OUTPUT_ENCODING)

        output = self._pt.render(None, translate, **c)
        return output.encode(client.charset)

    def __getitem__(self, name):
        return self._pt[name]

    def __getattr__(self, name):
        return getattr(self._pt, name)


Roundup Issue Tracker: http://roundup-tracker.org/