summaryrefslogtreecommitdiff
path: root/Mailman/database
diff options
context:
space:
mode:
authorBarry Warsaw2007-09-21 08:51:38 -0400
committerBarry Warsaw2007-09-21 08:51:38 -0400
commit65c64773d910b3b2a3e2a9b9db4669e57170ece2 (patch)
tree1bb742b2dc5898e569e19d8967e8d51a5d5c0352 /Mailman/database
parent892316be3c09eec4a1f8117bfd9eb44bba1c9117 (diff)
downloadmailman-65c64773d910b3b2a3e2a9b9db4669e57170ece2.tar.gz
mailman-65c64773d910b3b2a3e2a9b9db4669e57170ece2.tar.zst
mailman-65c64773d910b3b2a3e2a9b9db4669e57170ece2.zip
OMGW00T: After over a decade, the MailList mixin class is gone! Well,
mostly. It's no longer needed by anything in the test suite, and therefore the list manager returns database MailingList objects directly. The wrapper cruft has been removed. To accomplish this, a couple of hacks were added to the Mailman.app package, which will get cleaned up over time. The MailList module itself (and its few remaining mixins) aren't yet removed from the tree because some of the code is still not tested, and I want to leave this code around until I've finished converting it.
Diffstat (limited to 'Mailman/database')
-rw-r--r--Mailman/database/listmanager.py30
-rw-r--r--Mailman/database/model/mailinglist.py48
-rw-r--r--Mailman/database/model/requests.py12
3 files changed, 61 insertions, 29 deletions
diff --git a/Mailman/database/listmanager.py b/Mailman/database/listmanager.py
index d5a6303e6..0f6d7a9aa 100644
--- a/Mailman/database/listmanager.py
+++ b/Mailman/database/listmanager.py
@@ -17,7 +17,6 @@
"""SQLAlchemy/Elixir based provider of IListManager."""
-import weakref
import datetime
from elixir import *
@@ -34,9 +33,6 @@ from Mailman.interfaces import IListManager, IPending
class ListManager(object):
implements(IListManager)
- def __init__(self):
- self._objectmap = weakref.WeakKeyDictionary()
-
def create(self, fqdn_listname):
listname, hostname = split_listname(fqdn_listname)
mlist = MailingList.get_by(list_name=listname,
@@ -45,30 +41,18 @@ class ListManager(object):
raise Errors.MMListAlreadyExistsError(fqdn_listname)
mlist = MailingList(fqdn_listname)
mlist.created_at = datetime.datetime.now()
- # Wrap the database model object in an application MailList object and
- # return the latter. Keep track of the wrapper so we can clean it up
- # when we're done with it.
- from Mailman.MailList import MailList
- wrapper = MailList(mlist)
- self._objectmap[mlist] = wrapper
- return wrapper
+ return mlist
def delete(self, mlist):
- # Delete the wrapped backing data. XXX It's kind of icky to reach
- # into the MailList object this way.
- mlist._data.delete()
- mlist._data = None
+ mlist.delete()
def get(self, fqdn_listname):
listname, hostname = split_listname(fqdn_listname)
- mlist = MailingList.get_by(list_name=listname,
- host_name=hostname)
- if not mlist:
- return None
- mlist._restore()
- from Mailman.MailList import MailList
- wrapper = self._objectmap.setdefault(mlist, MailList(mlist))
- return wrapper
+ mlist = MailingList.get_by(list_name=listname, host_name=hostname)
+ if mlist is not None:
+ # XXX Fixme
+ mlist._restore()
+ return mlist
@property
def mailing_lists(self):
diff --git a/Mailman/database/model/mailinglist.py b/Mailman/database/model/mailinglist.py
index 0d12f919e..7fa9aca38 100644
--- a/Mailman/database/model/mailinglist.py
+++ b/Mailman/database/model/mailinglist.py
@@ -211,3 +211,51 @@ class MailingList(Entity):
# XXX Handle the case for when context is not None; those would be
# relative URLs.
return self.web_page_url + target + '/' + self.fqdn_listname
+
+ # IMailingListAddresses
+
+ @property
+ def posting_address(self):
+ return self.fqdn_listname
+
+ @property
+ def noreply_address(self):
+ return '%s@%s' % (config.NO_REPLY_ADDRESS, self.host_name)
+
+ @property
+ def owner_address(self):
+ return '%s-owner@%s' % (self.list_name, self.host_name)
+
+ @property
+ def request_address(self):
+ return '%s-request@%s' % (self.list_name, self.host_name)
+
+ @property
+ def bounces_address(self):
+ return '%s-bounces@%s' % (self.list_name, self.host_name)
+
+ @property
+ def join_address(self):
+ return '%s-join@%s' % (self.list_name, self.host_name)
+
+ @property
+ def leave_address(self):
+ return '%s-leave@%s' % (self.list_name, self.host_name)
+
+ @property
+ def subscribe_address(self):
+ return '%s-subscribe@%s' % (self.list_name, self.host_name)
+
+ @property
+ def unsubscribe_address(self):
+ return '%s-unsubscribe@%s' % (self.list_name, self.host_name)
+
+ def confirm_address(self, cookie):
+ template = string.Template(config.VERP_CONFIRM_FORMAT)
+ local_part = template.safe_substitute(
+ address = '%s-confirm' % self.list_name,
+ cookie = cookie)
+ return '%s@%s' % (local_part, self.host_name)
+
+ def __repr__(self):
+ return '<mailing list "%s" at %#x>' % (self.fqdn_listname, id(self))
diff --git a/Mailman/database/model/requests.py b/Mailman/database/model/requests.py
index b0aa0d8d0..ea917c2b9 100644
--- a/Mailman/database/model/requests.py
+++ b/Mailman/database/model/requests.py
@@ -49,22 +49,22 @@ class ListRequests:
@property
def count(self):
- results = _Request.select_by(mailing_list=self.mailing_list._data)
+ results = _Request.select_by(mailing_list=self.mailing_list)
return len(results)
def count_of(self, request_type):
- results = _Request.select_by(mailing_list=self.mailing_list._data,
+ results = _Request.select_by(mailing_list=self.mailing_list,
type=request_type)
return len(results)
@property
def held_requests(self):
- results = _Request.select_by(mailing_list=self.mailing_list._data)
+ results = _Request.select_by(mailing_list=self.mailing_list)
for request in results:
yield request
def of_type(self, request_type):
- results = _Request.select_by(mailing_list=self.mailing_list._data,
+ results = _Request.select_by(mailing_list=self.mailing_list,
type=request_type)
for request in results:
yield request
@@ -88,12 +88,12 @@ class ListRequests:
# flush()'s.
## result = _Request.table.insert().execute(
## key=key, type=request_type,
-## mailing_list=self.mailing_list._data,
+## mailing_list=self.mailing_list,
## data_hash=data_hash)
## row_id = result.last_inserted_ids()[0]
## return row_id
result = _Request(key=key, type=request_type,
- mailing_list=self.mailing_list._data,
+ mailing_list=self.mailing_list,
data_hash=data_hash)
# XXX We need a handle on last_inserted_ids() instead of requiring a
# flush of the database to get a valid id.