summaryrefslogtreecommitdiff
path: root/Mailman/interfaces
diff options
context:
space:
mode:
authorBarry Warsaw2007-08-07 23:24:13 -0500
committerBarry Warsaw2007-08-07 23:24:13 -0500
commit3fe9a220e8952853e51dbca359196d1f11dcbdc3 (patch)
tree0bcc80e3f4b52dee9c013e5ddda4c1abe23d8e02 /Mailman/interfaces
parent1236c0570b970e47a028c921812b694a699e8431 (diff)
downloadmailman-3fe9a220e8952853e51dbca359196d1f11dcbdc3.tar.gz
mailman-3fe9a220e8952853e51dbca359196d1f11dcbdc3.tar.zst
mailman-3fe9a220e8952853e51dbca359196d1f11dcbdc3.zip
Interfaces IRequests and IListRequests which are substitutes for the ListAdmin
mixin. This latter will go away soon. Added implementation and tests. The implementation has some cruft though -- it forces us to use a flush() in the code because I don't yet know how to get to SA's last_inserted_ids(). Note that this implementation abuses the IPendings interface in order to store arbitrary string key/value pairs. Fix the auto-discovery of interfaces by allowing Enums in interface files as well. Long term, this is how it should work anyway.
Diffstat (limited to 'Mailman/interfaces')
-rw-r--r--Mailman/interfaces/__init__.py7
-rw-r--r--Mailman/interfaces/pending.py8
-rw-r--r--Mailman/interfaces/requests.py87
3 files changed, 99 insertions, 3 deletions
diff --git a/Mailman/interfaces/__init__.py b/Mailman/interfaces/__init__.py
index e04ad1e78..7e8a3e123 100644
--- a/Mailman/interfaces/__init__.py
+++ b/Mailman/interfaces/__init__.py
@@ -18,6 +18,7 @@
import os
import sys
+from munepy import Enum
from zope.interface import implementedBy
from zope.interface.interfaces import IInterface
@@ -38,7 +39,11 @@ def _populate():
module = sys.modules[modname]
for name in dir(module):
obj = getattr(module, name)
- if IInterface.providedBy(obj):
+ try:
+ is_enum = issubclass(obj, Enum)
+ except TypeError:
+ is_enum = False
+ if IInterface.providedBy(obj) or is_enum:
setattr(iface_mod, name, obj)
__all__.append(name)
diff --git a/Mailman/interfaces/pending.py b/Mailman/interfaces/pending.py
index 5e26fbf6e..68a4c41de 100644
--- a/Mailman/interfaces/pending.py
+++ b/Mailman/interfaces/pending.py
@@ -15,9 +15,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-"""Interfaces for the pending database."""
+"""Interfaces for the pending database.
+
+The pending database contains events that must be confirmed by the user. It
+maps these events to a unique hash that can be used as a token for end user
+confirmation.
+"""
-from munepy import Enum
from zope.interface import Interface, Attribute
diff --git a/Mailman/interfaces/requests.py b/Mailman/interfaces/requests.py
new file mode 100644
index 000000000..0a817d43c
--- /dev/null
+++ b/Mailman/interfaces/requests.py
@@ -0,0 +1,87 @@
+# Copyright (C) 2007 by the Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+
+"""Interfaces for the request database.
+
+The request database handles events that must be approved by the list
+moderators, such as subscription requests and held messages.
+"""
+
+from munepy import Enum
+from zope.interface import Interface, Attribute
+
+
+
+class RequestType(Enum):
+ held_message = 1
+ subscription = 2
+ unsubscription = 3
+
+
+
+class IListRequests(Interface):
+ """Held requests for a specific mailing list."""
+
+ mailing_list = Attribute(
+ """The IMailingList for these requests.""")
+
+ count = Attribute(
+ """The total number of requests held for the mailing list.""")
+
+ def hold_request(request_type, key, data=None):
+ """Hold some data for moderator approval.
+
+ :param request_type: A `Request` enum value.
+ :param key: The key piece of request data being held.
+ :param data: Additional optional data in the form of a dictionary that
+ is associated with the held request.
+ :return: A unique id for this held request.
+ """
+
+ held_requests = Attribute(
+ """An iterator over the held requests, yielding a 2-tuple.
+
+ The tuple has the form: (id, type) where `id` is the held request's
+ unique id and the `type` is a `Request` enum value.
+ """)
+
+ def get_request(request_id):
+ """Get the data associated with the request id, or None.
+
+ :param request_id: The unique id for the request.
+ :return: A 2-tuple of the key and data originally held, or None if the
+ `request_id` is not in the database.
+ """
+
+ def delete_request(request_id):
+ """Delete the request associated with the id.
+
+ :param request_id: The unique id for the request.
+ :raises KeyError: If `request_id` is not in the database.
+ """
+
+
+
+class IRequests(Interface):
+ """The requests database."""
+
+ def get_list_requests(mailing_list):
+ """Return the `IListRequests` object for the given mailing list.
+
+ :param mailing_list: An `IMailingList`.
+ :return: An `IListRequests` object for the mailing list.
+ """