コード例 #1
0
ファイル: test_template.py プロジェクト: bogtan/Naaya
 def test_render_bad_template(self):
     templ = EmailPageTemplate(id='templ', text='<subject>asdf</subject>')
     try:
         templ.render_email()
         self.fail('Should have raised ValueError')
     except ValueError, e:
         self.assertTrue('Section "body_text" not found' in str(e))
コード例 #2
0
ファイル: email.py プロジェクト: pombredanne/trunk-eggs
    def _send_email_with_template(self, template_id, p_from, p_to, mail_opts):
        """ """
        try:
            email_tool = self.getEmailTool()

            template_text = email_tool._getOb(template_id).body
            template = EmailPageTemplate(template_id, template_text)
            mail_data = template.render_email(**mail_opts)

            p_subject = mail_data['subject']
            p_content = mail_data['body_text']

            return email_tool.sendEmail(p_content=p_content,
                                p_to=p_to,
                                p_from=p_from,
                                p_subject=p_subject)
        except Exception, e:
            zLOG.LOG('naaya.content.meeting.email', zLOG.WARNING,
                'Email sending failed for template %s - %s' % (template_id, str(e)))
            return 0
コード例 #3
0
ファイル: email.py プロジェクト: eaudeweb/trunk-eggs
    def _send_email_with_template(self, template_id, p_from, p_to, mail_opts):
        """ """
        try:
            email_tool = self.getEmailTool()

            template_text = email_tool._getOb(template_id).body
            template = EmailPageTemplate(template_id, template_text)
            mail_data = template.render_email(**mail_opts)

            p_subject = mail_data['subject']
            p_content = mail_data['body_text']

            return email_tool.sendEmail(p_content=p_content,
                                        p_to=p_to,
                                        p_from=p_from,
                                        p_subject=p_subject)
        except Exception, e:
            zLOG.LOG('naaya.content.meeting.email', zLOG.WARNING,
                     'Email sending failed for template %s - %s' %
                     (template_id, str(e)))
            return 0
コード例 #4
0
ファイル: test_template.py プロジェクト: bogtan/Naaya
    def test_render(self):
        test_template = (
            '<tal:block>\n'
            '<subject>Hello testing #<tal:block content="options/number" />\n'
            '</subject>\n'
            '<body_text>Test message to\n'
            ' check <tal:block content="options/item" /> rendering\n'
            '</body_text>\n'
            '<ignoreme></ignoreme>\n'
            '</tal:block>\n'
        )
        templ = EmailPageTemplate(id='templ', text=test_template)

        # make sure the page template is Persistent
        self.failUnless(issubclass(EmailPageTemplate, Item))

        render1 = templ.render_email(number=13, item=u"THING")
        self.assertEqual(render1, {
            'subject': 'Hello testing #13',
            'body_text': 'Test message to\n check THING rendering',
        })