~barry/mailman/templatecache

« back to all changes in this revision

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

  • Committer: Barry Warsaw
  • Date: 2012-01-30 15:37:16 UTC
  • Revision ID: barry@list.org-20120130153716-s9qx07i6i0rltyax
 * Held messages can now be moderated through the REST API.  Mailing list
   resources now accept a `held` path component.  GETing this returns all held
   messages for the mailing list.  POSTing to a specific request id under this
   url can dispose of the message using `Action` enums.
 * `IRequests` interface is removed.  Now just use adaptation from
   `IListRequests` directly (which takes an `IMailingList` object).
 * `handle_message()` now allows for `Action.hold` which is synonymous with
   `Action.defer` (since the message is already being held).
 * `IListRequests.get_request()` now takes an optional `request_type`
   argument to narrow the search for the given request.

- also, print_function is now a standard __future__ import.  The template has
  been updated, but add this to modules as you edit them.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# You should have received a copy of the GNU General Public License along with
16
16
# GNU Mailman.  If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
 
"""Implementations of the IRequests and IListRequests interfaces."""
 
18
"""Implementations of the pending requests interfaces."""
19
19
 
20
20
from __future__ import absolute_import, unicode_literals
21
21
 
22
22
__metaclass__ = type
23
23
__all__ = [
24
 
    'Requests',
25
24
    ]
26
25
 
27
26
 
34
33
from mailman.database.model import Model
35
34
from mailman.database.types import Enum
36
35
from mailman.interfaces.pending import IPendable, IPendings
37
 
from mailman.interfaces.requests import IListRequests, IRequests, RequestType
 
36
from mailman.interfaces.requests import IListRequests, RequestType
38
37
 
39
38
 
40
39
 
91
90
        config.db.store.add(request)
92
91
        return request.id
93
92
 
94
 
    def get_request(self, request_id):
 
93
    def get_request(self, request_id, request_type=None):
95
94
        result = config.db.store.get(_Request, request_id)
96
95
        if result is None:
97
96
            return None
 
97
        if request_type is not None and result.request_type != request_type:
 
98
            return None
98
99
        if result.data_hash is None:
99
100
            return result.key, result.data_hash
100
101
        pendable = getUtility(IPendings).confirm(
113
114
 
114
115
 
115
116
 
116
 
class Requests:
117
 
    implements(IRequests)
118
 
 
119
 
    def get_list_requests(self, mailing_list):
120
 
        return ListRequests(mailing_list)
121
 
 
122
 
 
123
 
 
124
117
class _Request(Model):
125
118
    """Table for mailing list hold requests."""
126
119