Hi.
How do I set a template for one specific list? I want one list to have a special footer template.
I have tried updating the database (template table) without effect so apparently the database is not used for templates or some kind of fallback is used to set it to the generic footer. Of course I also tried to restart mailman after that operation to try to rule out any caching-related problem.
I want to use a file://-path as that is the least painful way of doing it. I also would like a solution to place a file in a special location. My current templates are in a
.../var/templates/site/en/
structure with names like list:member:generic:footer.txt
Cheers // David
Hi.
Ok, checking the source helped. So I answer my own question:
mailman shell Welcome to the GNU Mailman shell
tm = getUtility(ITemplateManager) tm.set('list:member:regular:footer','mymaillist.example.com','file:///my_absolute_path/list:member:mymaillist.example.com:footer.txt') commit()
// David
On Sat, Sep 23, 2017 at 1:17 PM, David Krantz <gazorg@gmail.com> wrote:
Hi.
How do I set a template for one specific list? I want one list to have a special footer template.
I have tried updating the database (template table) without effect so apparently the database is not used for templates or some kind of fallback is used to set it to the generic footer. Of course I also tried to restart mailman after that operation to try to rule out any caching-related problem.
I want to use a file://-path as that is the least painful way of doing it. I also would like a solution to place a file in a special location. My current templates are in a
.../var/templates/site/en/
structure with names like list:member:generic:footer.txt
Cheers // David
Still two problems:
I do not know how to force a cache invalidation on a template. So only way to change is to set a new name on the file and change the uri there. Unpractical. No, restarts do not work.
the $user_delivered_to and $user_email do not expand for some reason. Known problem?
Cheers // David
On Sat, Sep 23, 2017 at 3:52 PM, David Krantz <gazorg@gmail.com> wrote:
Hi.
Ok, checking the source helped. So I answer my own question:
mailman shell Welcome to the GNU Mailman shell
tm = getUtility(ITemplateManager) tm.set('list:member:regular:footer','mymaillist.example.com','file:///my_absolute_path/list:member:mymaillist.example.com:footer.txt') commit()
// David
On Sat, Sep 23, 2017 at 1:17 PM, David Krantz <gazorg@gmail.com> wrote:
Hi.
How do I set a template for one specific list? I want one list to have a special footer template.
I have tried updating the database (template table) without effect so apparently the database is not used for templates or some kind of fallback is used to set it to the generic footer. Of course I also tried to restart mailman after that operation to try to rule out any caching-related problem.
I want to use a file://-path as that is the least painful way of doing it. I also would like a solution to place a file in a special location. My current templates are in a
.../var/templates/site/en/
structure with names like list:member:generic:footer.txt
Cheers // David
On 09/23/2017 07:36 AM, David Krantz wrote:
Still two problems:
- I do not know how to force a cache invalidation on a template. So only way to change is to set a new name on the file and change the uri there. Unpractical. No, restarts do not work.
Have you tried restarting/reloading whatever dbm (MySQL, PostgreSQL, ?) you are using?
- the $user_delivered_to and $user_email do not expand for some reason. Known problem?
These require that the list delivery be personalized. See <http://mailman.readthedocs.io/en/latest/src/mailman/runners/docs/outgoing.html#personalization>.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
On Sat, Sep 23, 2017 at 6:48 PM, Mark Sapiro <mark@msapiro.net> wrote:
Have you tried restarting/reloading whatever dbm (MySQL, PostgreSQL, ?) you are using?
No, that would have been strange to me; the table in the database was up to date. But now I tried that, I got no effect this time but I probably could set up a better test.
I also had another problem [solved]: I get the error message "Multiple rows were found for one_or_none" when I try TemplateManager.get(name, context) for the list. There is only one matching row in the templates table so something is fishy with the ORM. This occured when I changed to the previous uri value. As the database does not have any duplicates in the templates table I suspect either a broken join or that the cache retains the old value.
tm.get('list:member:regular:footer', 'test.example.com') Traceback (most recent call last): File "<console>", line 1, in <module> File ".../venv-3.5/lib/python3.5/site-packages/mailman-3.2.0a1-py3.5.egg/mailman/database/transaction.py",
The traceback looks like this in the mailman shell: line 85, in wrapper return function(args[0], config.db.store, *args[1:], **kws) File ".../venv-3.5/lib/python3.5/site-packages/mailman-3.2.0a1-py3.5.egg/mailman/model/template.py", line 98, in get contents = cache_mgr.get(actual_uri) File ".../venv-3.5/lib/python3.5/site-packages/mailman-3.2.0a1-py3.5.egg/mailman/database/transaction.py", line 85, in wrapper return function(args[0], config.db.store, *args[1:], **kws) File ".../venv-3.5/lib/python3.5/site-packages/mailman-3.2.0a1-py3.5.egg/mailman/model/cache.py", line 125, in get CacheEntry.key == key).one_or_none() File ".../venv-3.5/lib/python3.5/site-packages/SQLAlchemy-1.2.0b2-py3.5-linux-x86_64.egg/sqlalchemy/orm/query.py", line 2814, in one_or_none "Multiple rows were found for one_or_none()") sqlalchemy.orm.exc.MultipleResultsFound: Multiple rows were found for one_or_none()
Workaround: Delete cached files in .../var/cache and run delete from file_cache in postgresql. Then that works again. The culprit was that the file got cached twice so there is a bug in the cache function. I used the ITemplateManager-util in the shell to cause the problem.
- the $user_delivered_to and $user_email do not expand for some reason. Known problem?
These require that the list delivery be personalized. See <http://mailman.readthedocs.io/en/latest/src/mailman/runners/docs/outgoing.html#personalization>.
That explains things. Thank you!
Now I got two footers, first one without personalisation and one personalised. Interesting.
best regards // David
Hi again,
I had the problem with getting two footers, i.e. two expansions of the template. After some digging in the source code I found out that the decorator made one expansion (without personalization) and that the delivery handling made another (with personalization). So I hacked pipelines/builtin.py with a new pipeline that excluded the decorate step, recompiled and changed to that pipeline for my personalized list. That worked. Nothing like a bit of shotgun debugging in production.
That solves my immediate problem. Is there a known and recommended way of configuring personalized delivery so that you only get the personalized footer? I have ideas, but I probably should share them with the developer list instead. :-)
Of course this very nice functionality is a bit buried. I activated it using the interactive python shell, seems less risky than changing the database directly.
Cheers // David
On Sat, Sep 23, 2017 at 10:39 PM, David Krantz <gazorg@gmail.com> wrote:
On Sat, Sep 23, 2017 at 6:48 PM, Mark Sapiro <mark@msapiro.net> wrote:
Have you tried restarting/reloading whatever dbm (MySQL, PostgreSQL, ?) you are using?
No, that would have been strange to me; the table in the database was up to date. But now I tried that, I got no effect this time but I probably could set up a better test.
I also had another problem [solved]: I get the error message "Multiple rows were found for one_or_none" when I try TemplateManager.get(name, context) for the list. There is only one matching row in the templates table so something is fishy with the ORM. This occured when I changed to the previous uri value. As the database does not have any duplicates in the templates table I suspect either a broken join or that the cache retains the old value.
tm.get('list:member:regular:footer', 'test.example.com') Traceback (most recent call last): File "<console>", line 1, in <module> File ".../venv-3.5/lib/python3.5/site-packages/mailman-3.2.0a1-py3.5.egg/mailman/database/transaction.py",
The traceback looks like this in the mailman shell: line 85, in wrapper return function(args[0], config.db.store, *args[1:], **kws) File ".../venv-3.5/lib/python3.5/site-packages/mailman-3.2.0a1-py3.5.egg/mailman/model/template.py", line 98, in get contents = cache_mgr.get(actual_uri) File ".../venv-3.5/lib/python3.5/site-packages/mailman-3.2.0a1-py3.5.egg/mailman/database/transaction.py", line 85, in wrapper return function(args[0], config.db.store, *args[1:], **kws) File ".../venv-3.5/lib/python3.5/site-packages/mailman-3.2.0a1-py3.5.egg/mailman/model/cache.py", line 125, in get CacheEntry.key == key).one_or_none() File ".../venv-3.5/lib/python3.5/site-packages/SQLAlchemy-1.2.0b2-py3.5-linux-x86_64.egg/sqlalchemy/orm/query.py", line 2814, in one_or_none "Multiple rows were found for one_or_none()") sqlalchemy.orm.exc.MultipleResultsFound: Multiple rows were found for one_or_none()
Workaround: Delete cached files in .../var/cache and run delete from file_cache in postgresql. Then that works again. The culprit was that the file got cached twice so there is a bug in the cache function. I used the ITemplateManager-util in the shell to cause the problem.
- the $user_delivered_to and $user_email do not expand for some reason. Known problem?
These require that the list delivery be personalized. See <http://mailman.readthedocs.io/en/latest/src/mailman/runners/docs/outgoing.html#personalization>.
That explains things. Thank you!
Now I got two footers, first one without personalisation and one personalised. Interesting.
best regards // David
On 09/28/2017 01:56 PM, David Krantz wrote:
Hi again,
I had the problem with getting two footers, i.e. two expansions of the template. After some digging in the source code I found out that the decorator made one expansion (without personalization) and that the delivery handling made another (with personalization). So I hacked pipelines/builtin.py with a new pipeline that excluded the decorate step, recompiled and changed to that pipeline for my personalized list. That worked. Nothing like a bit of shotgun debugging in production.
That solves my immediate problem. Is there a known and recommended way of configuring personalized delivery so that you only get the personalized footer? I have ideas, but I probably should share them with the developer list instead. :-)
This is clearly a bug and should be fixed. If you report this issue at <https://gitlab.com/mailman/mailman/issues>, we will try to fix it.
Of course this very nice functionality is a bit buried. I activated it using the interactive python shell, seems less risky than changing the database directly.
There are many core settings not (yet) exposed in Postorius. This is something we need to fix, but it takes time and resources. In the mean time, 'mailman shell' is probably the best way to set them.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
On Fri, Sep 29, 2017 at 12:08 AM, Mark Sapiro <mark@msapiro.net> wrote:
On 09/28/2017 01:56 PM, David Krantz wrote: This is clearly a bug and should be fixed. If you report this issue at <https://gitlab.com/mailman/mailman/issues>, we will try to fix it.
I'll do that.
Of course this very nice functionality is a bit buried. I activated it using the interactive python shell, seems less risky than changing the database directly.
There are many core settings not (yet) exposed in Postorius. This is something we need to fix, but it takes time and resources. In the mean time, 'mailman shell' is probably the best way to set them.
It is okay and it works just fine. In the current version "mailman withlist" does not set a variable to a list, but it is easy enough to set it yourself if a bit poweruser-ish.
br // David
On 09/29/2017 01:33 PM, David Krantz wrote:
It is okay and it works just fine. In the current version "mailman withlist" does not set a variable to a list, but it is easy enough to set it yourself if a bit poweruser-ish.
It should if you use the '-l list@example.com' option. See
mailman withlist --help
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
On 09/29/2017 01:33 PM, David Krantz wrote:
On Fri, Sep 29, 2017 at 12:08 AM, Mark Sapiro <mark@msapiro.net> wrote:
This is clearly a bug and should be fixed. If you report this issue at <https://gitlab.com/mailman/mailman/issues>, we will try to fix it.
I'll do that.
@gazorg beat you to it. See <https://gitlab.com/mailman/mailman/issues/407> and feel free to comment there.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
On Fri, Sep 29, 2017 at 10:59 PM, Mark Sapiro <mark@msapiro.net> wrote:
@gazorg beat you to it. See <https://gitlab.com/mailman/mailman/issues/407> and feel free to comment there.
Well, that is me or at least my standard handle at gmail and similar. :-) I should set a footer in my email. Or find a better shortname.
// David
On 09/29/2017 02:05 PM, David Krantz wrote:
On Fri, Sep 29, 2017 at 10:59 PM, Mark Sapiro <mark@msapiro.net> wrote:
@gazorg beat you to it. See <https://gitlab.com/mailman/mailman/issues/407> and feel free to comment there.
Well, that is me or at least my standard handle at gmail and similar.
My oversight. Had I paid any attention to your email address, I would have known that. :(
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
On Sep 23, 2017, at 10:36, David Krantz <gazorg@gmail.com> wrote:
- I do not know how to force a cache invalidation on a template. So only way to change is to set a new name on the file and change the uri there. Unpractical. No, restarts do not work.
With Mark’s help you figured out how to use file templates, which is probably best for your use case. URL templates will be best when using a CMS or other system that allows you to upload templates into them. I can imagine Postorius one day supporting this feature.
The way to do cache invalidation for the template you added to the database would be (let’s say for mailing list alpha@example.com):
$ mailman shell -l alpha@example.com Welcome to the GNU Mailman shell The variable 'm' is the alpha@example.com mailing list
getUtility(ITemplateManager).delete('list:member:generic:footer', m.list_id)
More information is provided here:
https://gitlab.com/mailman/mailman/blob/master/src/mailman/interfaces/templa... http://mailman.readthedocs.io/en/latest/src/mailman/rest/docs/templates.html
Cheers, -Barry
On 09/23/2017 06:52 AM, David Krantz wrote:
Hi.
Ok, checking the source helped. So I answer my own question:
mailman shell Welcome to the GNU Mailman shell
tm = getUtility(ITemplateManager) tm.set('list:member:regular:footer','mymaillist.example.com','file:///my_absolute_path/list:member:mymaillist.example.com:footer.txt') commit()
You can also put templates in the default search path $var-dir/templates/. Sitewide ones in $var-dir/templates/site/, Domain specific in $var-dir/templates/domains/ and list specific ones in $var-dir/templates/lists/.
In this case $var-dir/templates/lists/mymaillist.example.com/en/list:member:regular:footer
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
I have currently two mail domains in Mailman 3 and one web domain (to avoid too many SSL certificates). When a user either signs up for a Mailman account or a subscribe to a list, I need to send them some information, like when I sign up for an account, I get a mail saying "Hello from [LISTNAME]!" ... "Please confirm".
Berry Warsaw provided[1] some links[2][3] to some documentation, but I don't see[2] any for site templates for account confirmation. Mark later mentioned[4] locations for template files for lists, domains and site.
What is the standard <context>:<recipient>:<type>:<name> for site-wide templates like account confirmation template in $var-dir/templates/site/[LANGUAGE]/ or similar using
tm.set('<context>:<recipient>:<type>:<name>','mymaillist.example.com','file:///my_absolute_path/<context>:<recipient>:<type>:<name>.txt')
?
[1]https://lists.mailman3.org/archives/list/mailman-users@mailman3.org/message/... [2]https://gitlab.com/mailman/mailman/blob/master/src/mailman/interfaces/templa... [3]https://mailman.readthedocs.io/en/latest/src/mailman/rest/docs/templates.htm... [4]https://lists.mailman3.org/archives/list/mailman-users@mailman3.org/message/...
participants (4)
-
Barry Warsaw
-
David Krantz
-
Henrik Rasmussen
-
Mark Sapiro