diff --git a/Products/EasyNewsletter/interfaces.py b/Products/EasyNewsletter/interfaces.py index 85e35c67..5faeda42 100644 --- a/Products/EasyNewsletter/interfaces.py +++ b/Products/EasyNewsletter/interfaces.py @@ -102,6 +102,4 @@ def preview_html(): class IBeforePersonalizationEvent(Interface): - html = Attribute('html to be personalized') - - data = Attribute('receiver specific data') + data = Attribute('issue specific data') diff --git a/Products/EasyNewsletter/issuedatafetcher.py b/Products/EasyNewsletter/issuedatafetcher.py index 6001409e..67cabac6 100644 --- a/Products/EasyNewsletter/issuedatafetcher.py +++ b/Products/EasyNewsletter/issuedatafetcher.py @@ -29,8 +29,7 @@ @implementer(IBeforePersonalizationEvent) class BeforePersonalizationEvent(object): - def __init__(self, html, data): - self.html = html + def __init__(self, data): self.data = data @@ -161,18 +160,20 @@ def _render_output_html(self): return output_html def _personalize(self, receiver, html): - tpl_context = {} - tpl_context['receiver'] = receiver - tpl_context['fullname'] = self._fullname(receiver) - tpl_context['salutation'] = self._salutation(receiver) - tpl_context['unsubscribe'] = self._unsubscribe_info(receiver) - tpl_context['UNSUBSCRIBE'] = tpl_context['unsubscribe']['html'] - tpl_context['SUBSCRIBER_SALUTATION'] = self._subscriber_salutation( + data = {} + data['html'] = html + data['context'] = {} + data['context']['receiver'] = receiver + data['context']['fullname'] = self._fullname(receiver) + data['context']['salutation'] = self._salutation(receiver) + data['context']['unsubscribe'] = self._unsubscribe_info(receiver) + data['context']['UNSUBSCRIBE'] = data['context']['unsubscribe']['html'] + data['context']['SUBSCRIBER_SALUTATION'] = self._subscriber_salutation( receiver ) - notify(BeforePersonalizationEvent(html, tpl_context)) - template = jinja2.Template(html.decode('utf8')) - return template.render(**tpl_context) + notify(BeforePersonalizationEvent(data)) + template = jinja2.Template(data['html'].decode('utf8')) + return template.render(**data['context']) def _personalize_texts(self, receiver, text, text_plain): # DEPRECATED @@ -289,7 +290,7 @@ def _create_plaintext_message(self, text): # to keep the message readable. anchorlist = "\n\n" + ("-" * plain_text_maxcols) + "\n\n" for counter, item in enumerate(parser.anchorlist): - anchorlist += "[%d] %s\n" % (counter, item) + anchorlist += "[{0:d}] {1:s}\n".format(counter, item) text = textout.getvalue() + anchorlist del textout, formtext, parser, anchorlist diff --git a/base.cfg b/base.cfg index 497a5deb..d4688ea1 100644 --- a/base.cfg +++ b/base.cfg @@ -40,6 +40,7 @@ recipe = zc.recipe.testrunner eggs = Products.EasyNewsletter[test] ipdb + defaults = ['-s', 'Products.EasyNewsletter', '--auto-color', '--auto-progress']