def render_slide(self, slide): if easytemplate_installed and \ self.settings.easytemplate_enabled: context = getTemplateContext(self.context, expose_schema=False) text, errors = applyTemplate(context, slide, logger) if not errors: slide = text return self.transform(slide)
def render_slide(self, slide): if easytemplate_installed and \ self.settings.easytemplate_enabled: context = getTemplateContext(self.context, expose_schema=False) text, errors = applyTemplate(context, slide, logger) if not errors: slide = text return self.transform(slide)
def getHeader(self): """ Get cooked portlet title. """ context = self.getTemplateContext() header = self.data.header header, errors = applyTemplate(context, header, logger) if errors: return "Errors" else: return header
def getHeader(self): """ Get cooked portlet title. """ context = self.getTemplateContext() header = self.data.header header, errors = applyTemplate(context, header, logger) if errors: return "Errors" else: return header
def getBody(self): """ Get cooked portlet body. """ context = self.getTemplateContext() text = self.data.text text, errors = applyTemplate(context, text, logger) if errors: # TODO: Handle errors gracefully return "Template contains errors. Please see the log." else: logger.debug("Got:" + text) return text
def getBody(self): """ Get cooked portlet body. """ context = self.getTemplateContext() text = self.data.text.raw text, errors = applyTemplate(context, text, logger) if errors: # TODO: Handle errors gracefully return "Template contains errors. Please see the log." else: logger.debug("Got:" + text) return text
def __call__(self): context = obj = self.event.object templateContext = getTemplateContext(context) # Flag if we have errors from any template formatter any_errors = False recipients, errors = applyTemplate(templateContext, self.element.recipients, logger=logger) any_errors |= errors if recipients == None: raise ValueError("Bad recipients value:" + str(self.element.recipients.encode("utf-8"))) emails = recipients.strip().split(",") emails = [ email for email in emails if (email != None and email != '')] recipients = [str(email.strip()) for email in emails] mailhost = getToolByName(aq_inner(self.context), "MailHost") if not mailhost: raise ComponentLookupError('You must have a Mailhost utility to execute this action') source = self.element.source source, errors = applyTemplate(templateContext, source, logger=logger) any_errors |= errors urltool = getToolByName(aq_inner(self.context), "portal_url") portal = urltool.getPortalObject() email_charset = portal.getProperty('email_charset') if not source or len(source) == 0: # no source provided, looking for the site wide from email # address from_address = portal.getProperty('email_from_address') if not from_address: raise ValueError, 'You must provide a source address for this \ action or enter an email in the portal properties' from_name = portal.getProperty('email_from_name') source = "%s <%s>" % (from_name, from_address) message, errors = applyTemplate(templateContext, self.element.message, logger=logger) any_errors |= errors #subject_source = self.sanify_encoding(self.element.subject) subject_source = self.element.subject subject, errors = applyTemplate(templateContext, subject_source, logger=logger) any_errors |= errors # TODO: Should these to be added to status messaegs if len(recipients) == 0: raise ValueError("Recipients could not be defined from template:" + self.element.recipients.encode("utf-8")) if subject == None or len(subject) == 0: raise ValueError("Subject could not be defined from template:" + self.element.subject.encode("utf-8")) if source == None or len(source) == 0: raise ValueError("Source could not be defined from template:" + self.element.source.encode("utf-8")) if any_errors: # These has been outputted already above return for email_recipient in recipients: assert len(email_recipient.strip()) > 0, "Email recipient is empty, all recipients:" + str(recipients) mailhost.secureSend(message, email_recipient, source, subject=subject, subtype='plain', charset=email_charset, debug=False) return True