Open dbitouze opened 7 years ago
Can you show the code you use to send the emails?
With a (string) property, say meeting_date
defined in the "Properties" tab in the ZMI at the root of the site, it is used in a Python script as:
context.meeting_date
and in easytemplate
's document template as:
{{ context.meeting_date.decode('utf-8') }}
Can you paste the code of the script that sends emails?
Can you paste the code of the script that sends emails?
context.MailHost.send(msg, mto=email, mfrom=context.email_from_address, subject=mSubj, charset = context.email_charset)
where, for instance, the mSubj
string is defined by something like the following:
mSubj = "[Our nice meeting] Save the date " + context.meeting_date.decode('utf-8')
You can read the contents of a snippet programmatically by going to the ".snippets" folder, e.g. site['.snippets'][snippetid].text.raw
In my case below the site name is 'Snippets' and I have stored the snippets in a folder named '.snippets':
$ bin/instance -OSnippets debug
Starting debugger (the name "app" is bound to the top-level Zope object)
>>> from zope.component.hooks import getSite
>>> site = getSite()
>>> site
<PloneSite at /Snippets>
>>> snippet=site['.snippets']['snippet-1']
>>> snippet
<Document at /Snippets/.snippets/snippet-1>
>>> snippet.text.raw
u'<p>October 16, 2017</p>'
>>> snippet.text.output
u'<p>October 16, 2017</p>'
>>>
You could also try changing the TAL expression in the Snippets Settings control panel. It defaults to context/text/output|context/getText|nothing
but you might be able to write an expression that strips the p
or other tags that wrap the content you really want.
Suppose you created a Plone 5 Web site for an annual meeting. The date of the meeting changes each year but is supposed to appear in many pages of the site and you consider to use an
uwosh.snippet
for it (as a replacement ofeasytemplate
which is not designed for Plone 5).The problem is, you also want to make this (changing) date to appear in mails automatically sent to people who registered and for this you want this snippet to be used in Python scripts.
This is possible for
easytemplate
snippets. Is it also the case foruwosh.snippet
ones?