Exemplo n.º 1
0
    def render(self, client, classname, request, **options):
        """Render this Page Template"""

        if not self._v_cooked:
            self._cook()

        __traceback_supplement__ = (
            PageTemplate.PageTemplateTracebackSupplement, self)

        if self._v_errors:
            raise PageTemplate.PTRuntimeError('Page Template %s has errors.' %
                                              self.id)

        # figure the context
        c = context(client, self, classname, request)
        c.update({'options': options})

        # and go
        output = StringIO()
        TALInterpreter.TALInterpreter(self._v_program,
                                      self.macros,
                                      getEngine().getContext(c),
                                      output,
                                      tal=1,
                                      strictinsert=0)()
        return output.getvalue()
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
 def __init__(self, client):
     self.client = client
     self.form = client.form
     self.db = client.db
     self.nodeid = client.nodeid
     self.template = client.template
     self.classname = client.classname
     self.userid = client.userid
     self.base = client.base
     self.user = client.user
     self.context = templating.context(client)
Exemplo n.º 4
0
 def __init__(self, client):
     self.client = client
     self.form = client.form
     self.db = client.db
     self.nodeid = client.nodeid
     self.template = client.template
     self.classname = client.classname
     self.userid = client.userid
     self.base = client.base
     self.user = client.user
     self.context = templating.context(client)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    def render(self, client, classname, request, **options):
        # [ ] limit the information passed to the minimal necessary set
        c = context(client, self, classname, request)

        c.update({
            'options': options,
            'gettext': lambda s: s2u(client.gettext(s)),
            'ngettext': lambda s, p, n: s2u(client.ngettext(s, p, n))
        })
        s = self._tpl.render(c)
        return s if sys.version_info[0] > 2 else \
            s.encode(client.STORAGE_CHARSET, )
Exemplo n.º 7
0
    def render(self, client, classname, request, **options):
        """Render this Page Template"""

        if not self._v_cooked:
            self._cook()

        __traceback_supplement__ = (PageTemplate.PageTemplateTracebackSupplement, self)

        if self._v_errors:
            raise PageTemplate.PTRuntimeError, \
                'Page Template %s has errors.'%self.id

        # figure the context
        c = context(client, self, classname, request)
        c.update({'options': options})

        # and go
        output = StringIO.StringIO()
        TALInterpreter.TALInterpreter(self._v_program, self.macros,
            getEngine().getContext(c), output, tal=1, strictinsert=0)()
        return output.getvalue()
Exemplo n.º 8
0
 def render(self, client, classname, request, **options):
     # [ ] limit the information passed to the minimal necessary set
     c = context(client, self, classname, request)
     c.update({'options': options})
     s = self._tpl.render(c)
     return s if sys.version_info[0] > 2 else s.encode(client.STORAGE_CHARSET, )
Exemplo n.º 9
0
 def render(self, client, classname, request, **options):
     # [ ] limit the information passed to the minimal necessary set
     c = context(client, self, classname, request)
     c.update({'options': options})
     return self._tpl.render(c).encode(client.charset, )
Exemplo n.º 10
0
 def render(self, client, classname, request, **options):
     # [ ] limit the information passed to the minimal necessary set
     c = context(client, self, classname, request)
     c.update({'options': options})
     return self._tpl.render(c).encode(client.charset, )