~barry/mailman/events-and-web

« back to all changes in this revision

Viewing changes to src/mailman/interfaces/requests.py

  • Committer: klm
  • Date: 1998-01-07 21:21:35 UTC
  • Revision ID: vcs-imports@canonical.com-19980107212135-sv0y521ps0xye37r
Initial revision

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2012 by the Free Software Foundation, Inc.
2
 
#
3
 
# This file is part of GNU Mailman.
4
 
#
5
 
# GNU Mailman is free software: you can redistribute it and/or modify it under
6
 
# the terms of the GNU General Public License as published by the Free
7
 
# Software Foundation, either version 3 of the License, or (at your option)
8
 
# any later version.
9
 
#
10
 
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
11
 
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13
 
# more details.
14
 
#
15
 
# You should have received a copy of the GNU General Public License along with
16
 
# GNU Mailman.  If not, see <http://www.gnu.org/licenses/>.
17
 
 
18
 
"""Interfaces for the request database.
19
 
 
20
 
The request database handles events that must be approved by the list
21
 
moderators, such as subscription requests and held messages.
22
 
"""
23
 
 
24
 
from __future__ import absolute_import, unicode_literals
25
 
 
26
 
__metaclass__ = type
27
 
__all__ = [
28
 
    'IListRequests',
29
 
    'RequestType',
30
 
    ]
31
 
 
32
 
 
33
 
from flufl.enum import Enum
34
 
from zope.interface import Interface, Attribute
35
 
 
36
 
 
37
 
 
38
 
class RequestType(Enum):
39
 
    held_message = 1
40
 
    subscription = 2
41
 
    unsubscription = 3
42
 
 
43
 
 
44
 
 
45
 
class IListRequests(Interface):
46
 
    """Held requests for a specific mailing list."""
47
 
 
48
 
    mailing_list = Attribute(
49
 
        """The IMailingList for these requests.""")
50
 
 
51
 
    count = Attribute(
52
 
        """The total number of requests held for the mailing list.""")
53
 
 
54
 
    def count_of(request_type):
55
 
        """The total number of requests held of the given request type.
56
 
 
57
 
        :param request_type: A `RequestType` enum value.
58
 
        :return: An integer.
59
 
        """
60
 
 
61
 
    def hold_request(request_type, key, data=None):
62
 
        """Hold some data for moderator approval.
63
 
 
64
 
        :param request_type: A `RequestType` enum value.
65
 
        :param key: The key piece of request data being held.
66
 
        :param data: Additional optional data in the form of a dictionary that
67
 
            is associated with the held request.
68
 
        :return: A unique id for this held request.
69
 
        """
70
 
 
71
 
    held_requests = Attribute(
72
 
        """An iterator over the held requests.
73
 
 
74
 
        Returned items have two attributes:
75
 
         * `id` is the held request's unique id;
76
 
         * `type` is a `RequestType` enum value.
77
 
        """)
78
 
 
79
 
    def of_type(request_type):
80
 
        """An iterator over the held requests of the given type.
81
 
 
82
 
        Returned items have two  attributes:
83
 
         * `id` is the held request's unique id;
84
 
         * `type` is a `RequestType` enum value.
85
 
 
86
 
         Only items with a matching `type' are returned.
87
 
         """
88
 
 
89
 
    def get_request(request_id, request_type):
90
 
        """Get the data associated with the request id, or None.
91
 
 
92
 
        :param request_id: The unique id for the request.
93
 
        :type request_id: int
94
 
        :param request_type: Optional request type that the requested id must
95
 
            match, otherwise no match is returned.
96
 
        :type request_type: `RequestType`
97
 
        :return: A 2-tuple of the key and data originally held, or None if the
98
 
            `request_id` is not in the database.
99
 
        """
100
 
 
101
 
    def delete_request(request_id):
102
 
        """Delete the request associated with the id.
103
 
 
104
 
        :param request_id: The unique id for the request.
105
 
        :raises KeyError: If `request_id` is not in the database.
106
 
        """