~abompard/mailman/sqlalchemy

« back to all changes in this revision

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

  • Committer: Abhilash Raj
  • Date: 2014-09-25 13:06:24 UTC
  • Revision ID: raj.abhilash1@gmail.com-20140925130624-uahqe0svszbycrtm
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()

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
                'Message ID already exists in message store: {0}'.format(
67
67
                    message_id))
68
68
        shaobj = hashlib.sha1(message_id)
69
 
        hash32 = base64.b32encode(shaobj.digest()).decode('ascii')
 
69
        hash32 = base64.b32encode(shaobj.digest())
70
70
        del message['X-Message-ID-Hash']
71
71
        message['X-Message-ID-Hash'] = hash32
72
72
        # Calculate the path on disk where we're going to store this message
115
115
 
116
116
    @dbconnection
117
117
    def get_message_by_hash(self, store, message_id_hash):
118
 
        if isinstance(message_id_hash, bytes):
119
 
            message_id_hash = message_id_hash.decode('utf-8')
 
118
        # It's possible the hash came from a message header, in which case it
 
119
        # will be a Unicode.  However when coming from source code, it may be
 
120
        # an 8-string.  Coerce to the latter if necessary; it must be
 
121
        # US-ASCII.
 
122
        if isinstance(message_id_hash, unicode):
 
123
            message_id_hash = message_id_hash.encode('ascii')
120
124
        row = store.query(Message).filter_by(
121
125
            message_id_hash=message_id_hash).first()
122
126
        if row is None: