summaryrefslogtreecommitdiff
path: root/src/mailman/model/messagestore.py
diff options
context:
space:
mode:
authorAbhilash Raj2014-09-25 18:36:24 +0530
committerAbhilash Raj2014-09-25 18:36:24 +0530
commit95fc64b4894e5985bb8d0e5e944b2cda38c9a58c (patch)
tree697f18eb33eddc8a16e2b09f4b4be4aaf0cf0dbe /src/mailman/model/messagestore.py
parentf2c619de76bd1614a6609f1a61e34ecf8a4344fc (diff)
downloadmailman-95fc64b4894e5985bb8d0e5e944b2cda38c9a58c.tar.gz
mailman-95fc64b4894e5985bb8d0e5e944b2cda38c9a58c.tar.zst
mailman-95fc64b4894e5985bb8d0e5e944b2cda38c9a58c.zip
Add support for postgresql
* revert changes in message_id_has encoding by barry * Change message_id_hash column to LargeBinary (from previously mistaken one i.e.unicode) * add missing import in database/types.py * fix a bug in database/Model.py, transaction has no method abort(), instead it is rollback()
Diffstat (limited to 'src/mailman/model/messagestore.py')
-rw-r--r--src/mailman/model/messagestore.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mailman/model/messagestore.py b/src/mailman/model/messagestore.py
index 225d3d1ce..0b8a0ac78 100644
--- a/src/mailman/model/messagestore.py
+++ b/src/mailman/model/messagestore.py
@@ -66,7 +66,7 @@ class MessageStore:
'Message ID already exists in message store: {0}'.format(
message_id))
shaobj = hashlib.sha1(message_id)
- hash32 = base64.b32encode(shaobj.digest()).decode('ascii')
+ hash32 = base64.b32encode(shaobj.digest())
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
@@ -115,8 +115,12 @@ class MessageStore:
@dbconnection
def get_message_by_hash(self, store, message_id_hash):
- if isinstance(message_id_hash, bytes):
- message_id_hash = message_id_hash.decode('utf-8')
+ # It's possible the hash came from a message header, in which case it
+ # will be a Unicode. However when coming from source code, it may be
+ # an 8-string. Coerce to the latter if necessary; it must be
+ # US-ASCII.
+ if isinstance(message_id_hash, unicode):
+ message_id_hash = message_id_hash.encode('ascii')
row = store.query(Message).filter_by(
message_id_hash=message_id_hash).first()
if row is None: