summaryrefslogtreecommitdiff
path: root/Mailman/MailList.py
diff options
context:
space:
mode:
authorbwarsaw2006-07-08 17:58:13 +0000
committerbwarsaw2006-07-08 17:58:13 +0000
commitf321ff8f419284c32f7eea4e06c83212bccef6b0 (patch)
tree7e1d1e1a1b8b81a48d86afb5c47eb039529993ac /Mailman/MailList.py
parent7a94dcd001240e0c06cc4b50017b8bfd097d9ff4 (diff)
downloadmailman-f321ff8f419284c32f7eea4e06c83212bccef6b0.tar.gz
mailman-f321ff8f419284c32f7eea4e06c83212bccef6b0.tar.zst
mailman-f321ff8f419284c32f7eea4e06c83212bccef6b0.zip
First crack at real virtual domain support, i.e. mailing lists with the same
name in more than one domain. - Totally eradicate MAILMAN_SITE_LIST, and in fact the entire need for a site list. The functions that the site list previously performed are either removed or supported in other ways. For example, instead of forwarding owner bounces to the site list, we now have a SITE_OWNER_ADDRESS which should point to a human, and such bounces are sent there instead. There's also a "no reply" email address that should be set up to go to devnull. For any message that never expects a reply, the sender is set to this address. - Remove the Site.py module. It was an experimental approach to trying to support virtual domains, and we're going to do it so much better now that this module is no longer necessary. Site._makedirs() -> Utils.makedir(). - VIRTUAL_HOST_OVERVIEW is completely removed, since now virtual hosts are always enabled. Virtual domains should be added to mailman.cfg by using the new add_domain() function. add_virtualhost() is gone. If no virtual domains are added explicitly, we add the default one that configure guessed (but we never add that if domains are added explicitly). - Utils.get_domain() -> Utils.get_request_domain() - withlist code cleanup and make sure that we load etc/mailman.cfg - A new base exception called MailmanException is added, from which all exceptions defined in Errors.py ultimately derive. MailmanError is retained and derives from MailmanException. - BadDomainSpecificationError is added. - Remove the -V/--virtual-host-overview option from list_lists and add instead -d/--domain and -f/--full. - bin/update probably works but needs more testing. - bin/newlist and bin/rmlist take fqdn list names, but default to the default domain if @whatever isn't given. newlist's -u/--urlhost and -e/--emailhost options are removed. The domain that the list is being added to must already exist. - Minor code cleanup in Message.py - Bump version to 2.2.0a1 - The Configuration object grows a .domain dictionary which maps email hosts to url hosts. The reverse mapping is supported, but not directly; use Configuration.get_email_host() instead. - Mailman/Cgi/create is converted from mm_cfg to config, and some minor code cleanup is performed. Also, convert to __i18n_templates__ = True. - New MailList APIs: + property .fqdn_listname + GetNoReplyEmail() + Create() API changes and refactoring.
Diffstat (limited to 'Mailman/MailList.py')
-rw-r--r--Mailman/MailList.py60
1 files changed, 36 insertions, 24 deletions
diff --git a/Mailman/MailList.py b/Mailman/MailList.py
index ecf449246..069a0b397 100644
--- a/Mailman/MailList.py
+++ b/Mailman/MailList.py
@@ -68,7 +68,6 @@ from Mailman import Gui
from Mailman import i18n
from Mailman import MemberAdaptor
from Mailman import Message
-from Mailman import Site
from Mailman.OldStyleMemberships import OldStyleMemberships
_ = i18n._
@@ -183,9 +182,13 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
def fullpath(self):
return self._full_path
+ @property
+ def fqdn_listname(self):
+ return '%s@%s' % (self._internal_name, self.host_name)
+
def getListAddress(self, extra=None):
if extra is None:
- return '%s@%s' % (self.internal_name(), self.host_name)
+ return self.fqdn_listname
return '%s-%s@%s' % (self.internal_name(), extra, self.host_name)
# For backwards compatibility
@@ -195,6 +198,9 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
def GetOwnerEmail(self):
return self.getListAddress('owner')
+ def GetNoReplyEmail(self):
+ return '%s@%s' % (config.NO_REPLY_ADDRESS, self.host_name)
+
def GetRequestEmail(self, cookie=''):
if config.VERP_CONFIRMATIONS and cookie:
return self.GetConfirmEmail(cookie)
@@ -273,7 +279,7 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
lifetime=config.LIST_LOCK_LIFETIME)
self._internal_name = name
if name:
- self._full_path = Site.get_listpath(name)
+ self._full_path = os.path.join(config.LIST_DATA_DIR, name)
else:
self._full_path = ''
# Only one level of mixin inheritance allowed
@@ -466,34 +472,41 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
#
# List creation
#
- def Create(self, name, admin, crypted_password,
- langs=None, emailhost=None):
- if Utils.list_exists(name):
- raise Errors.MMListAlreadyExistsError, name
- # Validate what will be the list's posting address. If that's
- # invalid, we don't want to create the mailing list. The hostname
- # part doesn't really matter, since that better already be valid.
- # However, most scripts already catch MMBadEmailError as exceptions on
- # the admin's email address, so transform the exception.
- if emailhost is None:
- emailhost = config.DEFAULT_EMAIL_HOST
- postingaddr = '%s@%s' % (name, emailhost)
+ def Create(self, fqdn_listname, admin_email, crypted_password, langs=None):
+ # Validate the list's posting address, which should be fqdn_listname.
+ # If that's invalid, do not create any of the mailing list artifacts
+ # (the subdir in lists/ and the subdirs in archives/public and
+ # archives/private. Most scripts already catch MMBadEmailError as
+ # exceptions on the admin's email address, so transform the exception.
+ if '@' not in fqdn_listname:
+ raise Errors.BadListNameError(fqdn_listname)
+ listname, email_host = fqdn_listname.split('@', 1)
+ if email_host not in config.domains:
+ raise Errors.BadDomainSpecificationError(email_host)
try:
- Utils.ValidateEmail(postingaddr)
+ Utils.ValidateEmail(fqdn_listname)
except Errors.MMBadEmailError:
- raise Errors.BadListNameError, postingaddr
+ raise Errors.BadListNameError(fqdn_listname)
+ # See if the mailing list already exists.
+ if Utils.list_exists(fqdn_listname):
+ raise Errors.MMListAlreadyExistsError(fqdn_listname)
# Validate the admin's email address
- Utils.ValidateEmail(admin)
- self._internal_name = name
- self._full_path = Site.get_listpath(name, create=1)
+ Utils.ValidateEmail(admin_email)
+ self._internal_name = listname
+ self._full_path = os.path.join(config.LIST_DATA_DIR, fqdn_listname)
+ Utils.makedirs(self._full_path)
# Don't use Lock() since that tries to load the non-existant config.pck
self.__lock.lock()
- self.InitVars(name, admin, crypted_password)
+ self.InitVars(listname, admin_email, crypted_password)
self.CheckValues()
if langs is None:
self.available_languages = [self.preferred_language]
else:
self.available_languages = langs
+ # Set the various host names
+ self.host_name = email_host
+ url_host = config.domains[email_host]
+ self.web_page_url = config.DEFAULT_URL_PATTERN % url_host
@@ -1350,7 +1363,6 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
addresses in the recipient headers.
"""
# This is the list's full address.
- listfullname = '%s@%s' % (self.internal_name(), self.host_name)
recips = []
# Check all recipient addresses against the list's explicit addresses,
# specifically To: Cc: and Resent-to:
@@ -1367,7 +1379,7 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
if (# TBD: backwards compatibility: deprecated
localpart == self.internal_name() or
# exact match against the complete list address
- addr == listfullname):
+ addr == self.fqdn_listname):
return True
recips.append((addr, localpart))
# Helper function used to match a pattern against an address.
@@ -1480,7 +1492,7 @@ bad regexp in bounce_matching_header line: %s
text = Utils.maketext(
'nomoretoday.txt',
{'sender' : sender,
- 'listname': '%s@%s' % (self.real_name, self.host_name),
+ 'listname': self.fqdn_listname,
'num' : count,
'owneremail': self.GetOwnerEmail(),
},