コード例 #1
0
ファイル: template.py プロジェクト: adviti/melange
  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
コード例 #2
0
ファイル: base.py プロジェクト: adviti/melange
  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)
コード例 #3
0
ファイル: template.py プロジェクト: rhyolight/nupic.son
    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
コード例 #4
0
ファイル: template.py プロジェクト: rhyolight/nupic.son
    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
コード例 #5
0
 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)
コード例 #6
0
 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)
コード例 #7
0
ファイル: render.py プロジェクト: rhyolight/nupic.son
 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)