def test_traceback_supplement(self): self.layer.logger.clear() class TBSupplementMock(object): def getInfo(self, as_html=0): return ' - Mock Supplement Info' class BugMock(object): def __call__(self): __traceback_supplement__ = (TBSupplementMock,) raise Exception('MockException') try: model = Model() request = self.layer.new_request() render_template( 'cone.tile:testdata/tile_exc_bug.pt', model=model, request=request, bugcall=BugMock() ) except Exception: pass self.checkOutput(""" Error while rendering tile template. Traceback (most recent call last): File "..._api.py", line ..., in render_template ... raise Exception('MockException') - Mock Supplement Info Exception: MockException """, self.layer.logger.messages[0])
def test_render_template(self): model = Model() request = self.layer.new_request() err = self.expectError( ValueError, render_template, '' ) self.assertEqual(str(err), 'Expected kwargs missing: model, request.') err = self.expectError( ValueError, render_template, '', model='foo' ) self.assertEqual(str(err), 'Expected kwargs missing: model, request.') err = self.expectError( ValueError, render_template, '', request='foo' ) self.assertEqual(str(err), 'Expected kwargs missing: model, request.') err = self.expectError( ValueError, render_template, 'testdata/tile1.pt', model=model, request=request ) self.assertEqual( str(err), 'Relative path not supported: testdata/tile1.pt' ) rendered = render_template( 'cone.tile:testdata/tile1.pt', model=model, request=request ) self.assertEqual(rendered, u'<span>Tile One</span>') request.environ['redirect'] = 'http://example.com/foo' rendered = render_template( 'cone.tile:testdata/tile1.pt', model=model, request=request ) self.assertEqual(rendered, u'') del request.environ['redirect']
def rendered_slice(self): """Rendered slice by ``slice_template``. """ return render_template(self.slice_template, request=self.request, model=self.model, context=self)
def rendertree(self, children, level=1): return render_template('cone.app.browser:templates/navtree_recue.pt', model=self.model, request=self.request, context=self, children=children, level=level)
def __call__(self, model, request): self.model = model self.request = request return render_template(self.template, request=request, model=model, context=self)
def __call__(self, model, request): self.model= model self.request = request return render_template(self.template, request=request, model=model, context=self)
def render(self): return render_template( self.template, request=self.request, model=self.model, context=self )
def rendered_footer(self): """Rendered footer by ``footer_template``. """ if not self.display_footer: return u'' return render_template(self.footer_template, request=self.request, model=self.model, context=self)
def rendered_slice(self): """Rendered slice by ``slice_template``. """ return render_template( self.slice_template, request=self.request, model=self.model, context=self )
def render(self): if self.model.properties.default_child: model = self.model[self.model.properties.default_child] return render_tile(model, self.request, 'content') return render_template( 'cone.app.browser:templates/default_root.pt', model=self.model, request=self.request, context=self)
def render(self): if self.model.properties.default_child: model = self.model[self.model.properties.default_child] return render_tile(model, self.request, 'content') if self.model.properties.default_content_tile: return render_tile(self.model, self.request, self.model.properties.default_content_tile) return render_template('cone.app.browser:templates/default_root.pt', model=self.model, request=self.request, context=self)
def rendered_footer(self): """Rendered footer by ``footer_template``. """ if not self.display_footer: return u'' return render_template( self.footer_template, request=self.request, model=self.model, context=self )
def __call__(_next, self, model, request): ajax_form_fiddle(request, '#content', 'inner') form = _next(self, model, request) if not form: form = u'' self.rendered_form = form path = self.path if not path: path = 'cone.app.browser:templates/content_form.pt' return render_template( path, request=request, model=model, context=self)
def __call__(_next, self, model, request): ajax_form_fiddle(request, '#content', 'inner') form = _next(self, model, request) if form is None: form = u'' self.rendered_form = form path = self.path if not path: path = 'cone.app.browser:templates/content_form.pt' return render_template( path, request=request, model=model, context=self)
def render(self): return render_template('cone.app.browser:templates/batch.pt', request=self.request, model=self.model, context=self)