summaryrefslogtreecommitdiff
path: root/mailman/interfaces/requests.py
diff options
context:
space:
mode:
authorBarry Warsaw2008-02-27 01:26:18 -0500
committerBarry Warsaw2008-02-27 01:26:18 -0500
commita1c73f6c305c7f74987d99855ba59d8fa823c253 (patch)
tree65696889450862357c9e05c8e9a589f1bdc074ac /mailman/interfaces/requests.py
parent3f31f8cce369529d177cfb5a7c66346ec1e12130 (diff)
downloadmailman-a1c73f6c305c7f74987d99855ba59d8fa823c253.tar.gz
mailman-a1c73f6c305c7f74987d99855ba59d8fa823c253.tar.zst
mailman-a1c73f6c305c7f74987d99855ba59d8fa823c253.zip
Diffstat (limited to 'mailman/interfaces/requests.py')
-rw-r--r--mailman/interfaces/requests.py105
1 files changed, 105 insertions, 0 deletions
diff --git a/mailman/interfaces/requests.py b/mailman/interfaces/requests.py
new file mode 100644
index 000000000..3d2e71c73
--- /dev/null
+++ b/mailman/interfaces/requests.py
@@ -0,0 +1,105 @@
+# Copyright (C) 2007-2008 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 count_of(request_type):
+ """The total number of requests held of the given request type.
+
+ :param request_type: A `RequestType` enum value.
+ :return: An integer.
+ """
+
+ def hold_request(request_type, key, data=None):
+ """Hold some data for moderator approval.
+
+ :param request_type: A `RequestType` 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.
+
+ Returned items have two attributes:
+ * `id` is the held request's unique id;
+ * `type` is a `RequestType` enum value.
+ """)
+
+ def of_type(request_type):
+ """An iterator over the held requests of the given type.
+
+ Returned items have two attributes:
+ * `id` is the held request's unique id;
+ * `type` is a `RequestType` enum value.
+
+ Only items with a matching `type' are returned.
+ """
+
+ 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.
+ """