~abompard/mailman/bug-1312884

« back to all changes in this revision

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

  • Committer: Barry Warsaw
  • Date: 2014-11-01 16:49:15 UTC
  • mfrom: (7251.1.38 abhilash)
  • Revision ID: barry@list.org-20141101164915-06wqfmya6wf47n6n
Database
--------
 * The ORM layer, previously implemented with Storm, has been replaced by
   SQLAlchemy, thanks to the fantastic work by Abhilash Raj and Aurélien
   Bompard.  Alembic is now used for all database schema migrations.
 * The new logger `mailman.database` logs any errors at the database layer.

API
---
 * Several changes to the internal API:
   - `IListManager.mailing_lists` is guaranteed to be sorted in List-ID order.
   - `IDomains.mailing_lists` is guaranteed to be sorted in List-ID order.
   - Iteration over domains via the `IDomainManager` is guaranteed to be sorted
     by `IDomain.mail_host` order.
   - `ITemporaryDatabase` interface and all implementations are removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    'Message',
25
25
    ]
26
26
 
27
 
from storm.locals import AutoReload, Int, RawStr, Unicode
 
27
from sqlalchemy import Column, Integer, LargeBinary, Unicode
28
28
from zope.interface import implementer
29
29
 
30
30
from mailman.database.model import Model
37
37
class Message(Model):
38
38
    """A message in the message store."""
39
39
 
40
 
    id = Int(primary=True, default=AutoReload)
41
 
    message_id = Unicode()
42
 
    message_id_hash = RawStr()
43
 
    path = RawStr()
 
40
    __tablename__ = 'message'
 
41
 
 
42
    id = Column(Integer, primary_key=True)
44
43
    # This is a Messge-ID field representation, not a database row id.
 
44
    message_id = Column(Unicode)
 
45
    message_id_hash = Column(LargeBinary)
 
46
    path = Column(LargeBinary)
45
47
 
46
48
    @dbconnection
47
49
    def __init__(self, store, message_id, message_id_hash, path):