def render(self): """Renders the template to a string. Uses the context method to retrieve the appropriate context, uses the self.templatePath() method to retrieve the template that should be used. """ try: context = context_helper.default(self.data) context.update(self.context()) rendered = loader.render_to_string(self.templatePath(), dictionary=context) except Exception, e: logging.exception(e) raise e
def render(self, template_path, render_context): """Renders the page using the specified context. The page is rendered using the template and context specified and is written to the response object. The context object is extended with the values from helper.context.default. Args: template_path: the path of the template that should be used render_context: the context that should be used """ context = context_helper.default(self.data) context.update(render_context) rendered = loader.render_to_string(template_path, dictionary=context) self.response.write(rendered)
def render(self): """Renders the template to a string. Uses the context method to retrieve the appropriate context, uses the self.templatePath() method to retrieve the template that should be used. """ try: context = context_helper.default(self.data) context.update(self.context()) # TODO(daniel): remove the abstract method template_path = getattr(self, "template_path", "") or self.templatePath() rendered = loader.render_to_string(template_path, dictionary=context) except Exception as e: logging.exception(e) raise e return rendered
def render(self): """Renders the template to a string. Uses the context method to retrieve the appropriate context, uses the self.templatePath() method to retrieve the template that should be used. """ try: context = context_helper.default(self.data) context.update(self.context()) # TODO(daniel): remove the abstract method template_path = getattr(self, 'template_path', '') or self.templatePath() rendered = loader.render_to_string(template_path, dictionary=context) except Exception as e: logging.exception(e) raise e return rendered
def get(self): template_path = 'summerofcode/shipment_tracking/picker.html' result_url = links.SOC_LINKER.program( self.data.program, url_names.GSOC_CREATE_SHIPMENT_INFO) context = context_helper.default(self.data) form_dict = self.shipment_info.to_dict() if self.shipment_info else None form_data = self.data.POST or form_dict form = ShipmentInfoForm(data=form_data) error = bool(form.errors) context.update({ 'access_token': decorator.credentials.access_token, 'client_id': decorator.credentials.client_id, 'developer_key': "AIzaSyCf5d-klzRMYCninhqaWx5zFp8GiHI6TWM", 'error': error, 'forms': [form], 'page_name': 'Select a tracking spreadsheet', 'result_url': result_url, }) response_content = self.renderer.render(self.data, template_path, context) self.response.write(response_content)
def get(self): template_path = 'summerofcode/shipment_tracking/picker.html' result_url = links.SOC_LINKER.program( self.data.program, url_names.GSOC_CREATE_SHIPMENT_INFO) context = context_helper.default(self.data) form_dict = self.shipment_info.to_dict( ) if self.shipment_info else None form_data = self.data.POST or form_dict form = ShipmentInfoForm(data=form_data) error = bool(form.errors) context.update({ 'access_token': decorator.credentials.access_token, 'client_id': decorator.credentials.client_id, 'developer_key': "AIzaSyCf5d-klzRMYCninhqaWx5zFp8GiHI6TWM", 'error': error, 'forms': [form], 'page_name': 'Select a tracking spreadsheet', 'result_url': result_url, }) response_content = self.renderer.render(self.data, template_path, context) self.response.write(response_content)
def render(self, data, template_path, context): """See Renderer.render for specification.""" render_context = soc_context_helper.default(data) render_context.update(context) return loader.render_to_string(template_path, dictionary=render_context)