summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBarry Warsaw2014-12-01 22:02:08 -0500
committerBarry Warsaw2014-12-01 22:02:08 -0500
commit590c96831bd03f193d07a063b8ee35b14416dc28 (patch)
tree16f9a675452eb389200642bfec97d6090696de57 /src
parent44e43727be13e3554342c2b5b75b7dc42abdb18c (diff)
downloadmailman-590c96831bd03f193d07a063b8ee35b14416dc28.tar.gz
mailman-590c96831bd03f193d07a063b8ee35b14416dc28.tar.zst
mailman-590c96831bd03f193d07a063b8ee35b14416dc28.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/model/message.py6
-rw-r--r--src/mailman/model/messagestore.py8
-rw-r--r--src/mailman/model/pending.py7
-rw-r--r--src/mailman/model/requests.py4
4 files changed, 12 insertions, 13 deletions
diff --git a/src/mailman/model/message.py b/src/mailman/model/message.py
index 691861d46..099e5a511 100644
--- a/src/mailman/model/message.py
+++ b/src/mailman/model/message.py
@@ -24,7 +24,7 @@ __all__ = [
'Message',
]
-from sqlalchemy import Column, Integer, LargeBinary, Unicode
+from sqlalchemy import Column, Integer, Unicode
from zope.interface import implementer
from mailman.database.model import Model
@@ -42,8 +42,8 @@ class Message(Model):
id = Column(Integer, primary_key=True)
# This is a Messge-ID field representation, not a database row id.
message_id = Column(Unicode)
- message_id_hash = Column(LargeBinary)
- path = Column(LargeBinary)
+ message_id_hash = Column(Unicode)
+ path = Column(Unicode)
@dbconnection
def __init__(self, store, message_id, message_id_hash, path):
diff --git a/src/mailman/model/messagestore.py b/src/mailman/model/messagestore.py
index 19b87c610..648bb6d04 100644
--- a/src/mailman/model/messagestore.py
+++ b/src/mailman/model/messagestore.py
@@ -64,8 +64,8 @@ class MessageStore:
raise ValueError(
'Message ID already exists in message store: {0}'.format(
message_id))
- shaobj = hashlib.sha1(message_id)
- hash32 = base64.b32encode(shaobj.digest())
+ shaobj = hashlib.sha1(message_id.encode('utf-8'))
+ hash32 = base64.b32encode(shaobj.digest()).decode('utf-8')
del message['X-Message-ID-Hash']
message['X-Message-ID-Hash'] = hash32
# Calculate the path on disk where we're going to store this message
@@ -90,7 +90,7 @@ class MessageStore:
# them and try again.
while True:
try:
- with open(path, 'w') as fp:
+ with open(path, 'wb') as fp:
# -1 says to use the highest protocol available.
pickle.dump(message, fp, -1)
break
@@ -102,7 +102,7 @@ class MessageStore:
def _get_message(self, row):
path = os.path.join(config.MESSAGES_DIR, row.path)
- with open(path) as fp:
+ with open(path, 'rb') as fp:
return pickle.load(fp)
@dbconnection
diff --git a/src/mailman/model/pending.py b/src/mailman/model/pending.py
index 49b12c16a..b3b239af6 100644
--- a/src/mailman/model/pending.py
+++ b/src/mailman/model/pending.py
@@ -31,8 +31,7 @@ import random
import hashlib
from lazr.config import as_timedelta
-from sqlalchemy import (
- Column, DateTime, ForeignKey, Integer, LargeBinary, Unicode)
+from sqlalchemy import Column, DateTime, ForeignKey, Integer, Unicode
from sqlalchemy.orm import relationship
from zope.interface import implementer
from zope.interface.verify import verifyObject
@@ -71,7 +70,7 @@ class Pended(Model):
__tablename__ = 'pended'
id = Column(Integer, primary_key=True)
- token = Column(LargeBinary)
+ token = Column(Unicode)
expiration_date = Column(DateTime)
key_values = relationship('PendedKeyValue')
@@ -108,7 +107,7 @@ class Pendings:
right_now = time.time()
x = random.random() + right_now % 1.0 + time.clock() % 1.0
# Use sha1 because it produces shorter strings.
- token = hashlib.sha1(repr(x)).hexdigest()
+ token = hashlib.sha1(repr(x).encode('utf-8')).hexdigest()
# In practice, we'll never get a duplicate, but we'll be anal
# about checking anyway.
if store.query(Pended).filter_by(token=token).count() == 0:
diff --git a/src/mailman/model/requests.py b/src/mailman/model/requests.py
index 24575d3c8..394084b71 100644
--- a/src/mailman/model/requests.py
+++ b/src/mailman/model/requests.py
@@ -33,7 +33,7 @@ from mailman.database.types import Enum
from mailman.interfaces.pending import IPendable, IPendings
from mailman.interfaces.requests import IListRequests, RequestType
from six.moves.cPickle import dumps, loads
-from sqlalchemy import Column, ForeignKey, Integer, LargeBinary, Unicode
+from sqlalchemy import Column, ForeignKey, Integer, Unicode
from sqlalchemy.orm import relationship
from zope.component import getUtility
from zope.interface import implementer
@@ -155,7 +155,7 @@ class _Request(Model):
id = Column(Integer, primary_key=True)
key = Column(Unicode)
request_type = Column(Enum(RequestType))
- data_hash = Column(LargeBinary)
+ data_hash = Column(Unicode)
mailing_list_id = Column(Integer, ForeignKey('mailinglist.id'), index=True)
mailing_list = relationship('MailingList')