Пример #1
0
 def render_and_send(self, template_name, additional_template_values):
   DEBUG = os.environ['SERVER_SOFTWARE'].startswith('Dev')
   template_values = {
     'full_width':620,
     'link_style':'style="text-decoration:none;color:#000099;"',
   }
   template_values.update(additional_template_values)
   template_values['host_url'] = ('http://localhost:8080' if DEBUG else 'http://www.admonymous.com')
   path_html = os.path.join(base_dir.base_dir(), 'templates', '_email', template_name+'.html')
   path_txt = os.path.join(base_dir.base_dir(), 'templates', '_email', template_name+'.txt')
   self.html = template.render(path_html, template_values, debug=False)
   self.body = template.render(path_txt, template_values, debug=False)
   if DEBUG:
     logging.info("""
     
     HTML Version:
     
     %s
     
     TXT Version:
     
     %s
     
     """ % (self.html, self.body))
   else:
     self.send()
Пример #2
0
 def render(self, template_name, additional_template_values):
   DEBUG = os.environ['SERVER_SOFTWARE'].startswith('Dev')
   template_values = {
     'full_width':620,
     'link_style':'style="text-decoration:none;color:#000099;"',
   }
   template_values.update(additional_template_values)
   template_values['host_url'] = ('http://localhost:8080' if DEBUG else 'http://www.admonymous.com')
   path_html = os.path.join(base_dir.base_dir(), 'templates', '_email', template_name+'.html')
   path_txt = os.path.join(base_dir.base_dir(), 'templates', '_email', template_name+'.txt')
   return {'html':template.render(path_html, template_values, debug=False), 'txt':template.render(path_txt, template_values, debug=False)}