~barry/mailman/lp1423756

« back to all changes in this revision

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

  • Committer: Barry Warsaw
  • Date: 2015-01-05 01:20:33 UTC
  • mfrom: (7264.4.66 py3)
  • Revision ID: barry@list.org-20150105012033-zdrw9c2odhpf22fz
Merge the Python 3 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Implementations of the pending requests interfaces."""
19
19
 
20
 
from __future__ import absolute_import, print_function, unicode_literals
21
 
 
22
 
__metaclass__ = type
23
20
__all__ = [
 
21
    'DataPendable',
 
22
    'ListRequests',
24
23
    ]
25
24
 
26
25
 
27
 
from cPickle import dumps, loads
 
26
import six
 
27
 
28
28
from datetime import timedelta
29
 
from sqlalchemy import Column, ForeignKey, Integer, LargeBinary, Unicode
30
 
from sqlalchemy.orm import relationship
31
 
from zope.component import getUtility
32
 
from zope.interface import implementer
33
 
 
34
29
from mailman.database.model import Model
35
30
from mailman.database.transaction import dbconnection
36
31
from mailman.database.types import Enum
37
32
from mailman.interfaces.pending import IPendable, IPendings
38
33
from mailman.interfaces.requests import IListRequests, RequestType
 
34
from six.moves.cPickle import dumps, loads
 
35
from sqlalchemy import Column, ForeignKey, Integer, Unicode
 
36
from sqlalchemy.orm import relationship
 
37
from zope.component import getUtility
 
38
from zope.interface import implementer
39
39
 
40
40
 
41
41
 
50
50
        # such a way that it will be properly reconstituted when unpended.
51
51
        clean_mapping = {}
52
52
        for key, value in mapping.items():
53
 
            assert isinstance(key, basestring)
54
 
            if not isinstance(value, unicode):
 
53
            assert isinstance(key, six.string_types)
 
54
            if not isinstance(value, six.text_type):
55
55
                key = '_pck_' + key
56
56
                value = dumps(value).decode('raw-unicode-escape')
57
57
            clean_mapping[key] = value
154
154
    id = Column(Integer, primary_key=True)
155
155
    key = Column(Unicode)
156
156
    request_type = Column(Enum(RequestType))
157
 
    data_hash = Column(LargeBinary)
 
157
    data_hash = Column(Unicode)
158
158
 
159
159
    mailing_list_id = Column(Integer, ForeignKey('mailinglist.id'), index=True)
160
160
    mailing_list = relationship('MailingList')