I am using a global ban to stop anyone not in a list of valid domains from being able to subscribe to any of our lists. This ban needs to be maintained using the Mailman3 api as it is being fed from another source.
I can create the ban fine by the following:
from mailmanclient import Client client = Client(URI,apiuser,apipass) client.bans.add("^(?!.*@\.")
client.bans[0].delete() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/wanout/.local/lib/python3.6/site-packages/mailmanclient/restbase/base.py",
However, I cannot seem to be able to remove it using the api: line 137, in delete self._connection.call(self._url, method='DELETE') File "/home/wanout/.local/lib/python3.6/site-packages/mailmanclient/restbase/connection.py", line 99, in call raise HTTPError(url, response.status, content, response, None) urllib.error.HTTPError: HTTP Error 404: b''
client.bans.remove(str(client.bans[0])) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/wanout/.local/lib/python3.6/site-packages/mailmanclient/restobjects/ban.py",
Or line 83, in remove ban.delete() File "/home/wanout/.local/lib/python3.6/site-packages/mailmanclient/restbase/base.py", line 137, in delete self._connection.call(self._url, method='DELETE') File "/home/wanout/.local/lib/python3.6/site-packages/mailmanclient/restbase/connection.py", line 99, in call raise HTTPError(url, response.status, content, response, None) urllib.error.HTTPError: HTTP Error 404: b''
client.bans.remove("^(?!.*@\.)") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/wanout/.local/lib/python3.6/site-packages/mailmanclient/restobjects/ban.py",
Or line 83, in remove ban.delete() File "/home/wanout/.local/lib/python3.6/site-packages/mailmanclient/restbase/base.py", line 137, in delete self._connection.call(self._url, method='DELETE') File "/home/wanout/.local/lib/python3.6/site-packages/mailmanclient/restbase/connection.py", line 99, in call raise HTTPError(url, response.status, content, response, None) urllib.error.HTTPError: HTTP Error 404: b''
And also, when I now try and go into the mailman-core docker image to use the mailman.interfaces.bans, it will not let me see the global bans:
from mailman.interfaces.bans import IBanManager global_bans = IBanManager(None) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: ('Could not adapt', None, <InterfaceClass mailman.interfaces.bans.IBanManager>)
I have opened an issue in Gitlab for this as I feel it may be a bug related to regex and global bans (there was a similar one for list banned addresses): https://gitlab.com/mailman/mailman/issues/598
Many thanks for your time,
--
*Nathan Dixon* MEng Senior Software Architect m: +44 (0)7402 690311
t: +44 (0)20 81231252 e: nathan.dixon@evadon.com w: www.evadon.com
This e-mail and any attachments are confidential and may be protected by legal, professional or other privilege. If you are not the intended recipient you should not store it, copy it, re-transmit it, use it or disclose its contents, but should return it to the sender immediately and delete your copy from your system. The views expressed are those of the sender and not necessarily those of Evadon. Please note that whilst we scan all e-mails for viruses we cannot guarantee that any e-mail is virus-free. Please be advised that we expressly reserve the right to monitor email content for the purposes of ensuring compliance with legal requirements and company policies and your sending to, or receiving from, us of any email constitutes your agreement to these terms.
Evadon Dynamics Limited, registered in England No. 09494097. Registered Office: Electric Works, Sheffield Digital Campus, 3 Concourse Way, Sheffield, S1 2BJ
On 5/15/19 9:46 AM, Nathan Dixon wrote:
I can create the ban fine by the following:
from mailmanclient import Client client = Client(URI,apiuser,apipass) client.bans.add("^(?!.*@\.")
This is apparently a typo - missing ')' - in the re as you have it correct below.
However, I cannot seem to be able to remove it using the api:
client.bans[0].delete() ... client.bans.remove(str(client.bans[0])) ...
client.bans.remove("^(?!.*@\.)")
All of the above work for me with both API 3.0 and 3.1 in a non-docker install of the current GitLab HEADs
And also, when I now try and go into the mailman-core docker image to use the mailman.interfaces.bans, it will not let me see the global bans:
from mailman.interfaces.bans import IBanManager global_bans = IBanManager(None) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: ('Could not adapt', None, <InterfaceClass mailman.interfaces.bans.IBanManager>)
I don't see this either.
I have opened an issue in Gitlab for this as I feel it may be a bug related to regex and global bans (there was a similar one for list banned addresses): https://gitlab.com/mailman/mailman/issues/598
I also commented on the GitLab issue. I think this must be an issue with the docker images.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
For those who are interested. To be able to use global_bans = IBanManager(None) and not get the following error:
Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: ('Could not adapt', None, <InterfaceClass mailman.interfaces.bans.IBanManager>)
You need to use: mailman shell Not a standard python3 session.
To actually update the global bans not via the API, which has some limitations at the moment (see the issue on Gitlab), I have done the following workaround (later I will put in checks for an existing ban to do an update instead, or a delete then create of the new ban):
I create a python script within the docker container within the existing PYTHONPATH that will be the module that runs when I want to create or update my ban (in this case under /usr/bin/) #!/bin/env python def create_valid_domains_ban(valid_domains_regex): from mailman.interfaces.bans import IBanManager global_bans = IBanManager(None) global_bans.ban(valid_domains_regex) print(list(global_bans.bans)[0].email)
I can then invoke this as a mailman module from the server using docker exec mailman-core mailman shell -r create_valid_domains_ban $valid_domains_regex
On Wed, 15 May 2019 at 21:21, Mark Sapiro <mark@msapiro.net> wrote:
On 5/15/19 9:46 AM, Nathan Dixon wrote:
I can create the ban fine by the following:
from mailmanclient import Client client = Client(URI,apiuser,apipass)
client.bans.add("^(?!.*@\.")
This is apparently a typo - missing ')' - in the re as you have it correct below.
However, I cannot seem to be able to remove it using the api:
client.bans[0].delete() ... client.bans.remove(str(client.bans[0])) ...
client.bans.remove("^(?!.*@\.)")
All of the above work for me with both API 3.0 and 3.1 in a non-docker install of the current GitLab HEADs
And also, when I now try and go into the mailman-core docker image to use the mailman.interfaces.bans, it will not let me see the global bans:
from mailman.interfaces.bans import IBanManager global_bans = IBanManager(None) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: ('Could not adapt', None, <InterfaceClass mailman.interfaces.bans.IBanManager>)
I don't see this either.
I have opened an issue in Gitlab for this as I feel it may be a bug related to regex and global bans (there was a similar one for list banned addresses): https://gitlab.com/mailman/mailman/issues/598
I also commented on the GitLab issue. I think this must be an issue with the docker images.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Mailman-users mailing list -- mailman-users@mailman3.org To unsubscribe send an email to mailman-users-leave@mailman3.org https://lists.mailman3.org/mailman3/lists/mailman-users.mailman3.org/
--
*Nathan Dixon* MEng Senior Software Architect m: +44 (0)7402 690311
t: +44 (0)20 81231252 e: nathan.dixon@evadon.com w: www.evadon.com
This e-mail and any attachments are confidential and may be protected by legal, professional or other privilege. If you are not the intended recipient you should not store it, copy it, re-transmit it, use it or disclose its contents, but should return it to the sender immediately and delete your copy from your system. The views expressed are those of the sender and not necessarily those of Evadon. Please note that whilst we scan all e-mails for viruses we cannot guarantee that any e-mail is virus-free. Please be advised that we expressly reserve the right to monitor email content for the purposes of ensuring compliance with legal requirements and company policies and your sending to, or receiving from, us of any email constitutes your agreement to these terms.
Evadon Dynamics Limited, registered in England No. 09494097. Registered Office: Electric Works, Sheffield Digital Campus, 3 Concourse Way, Sheffield, S1 2BJ
participants (2)
-
Mark Sapiro
-
Nathan Dixon