Merge branch 'alias' into 'master'
[mailman.git] / src / mailman / model / message.py
blob24f891b0ceadf9f9f92f631e49c216215167c0cf
1 # Copyright (C) 2007-2019 by the Free Software Foundation, Inc.
3 # This file is part of GNU Mailman.
5 # GNU Mailman is free software: you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option)
8 # any later version.
10 # GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 # more details.
15 # You should have received a copy of the GNU General Public License along with
16 # GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
18 """Model for messages."""
20 from mailman.database.model import Model
21 from mailman.database.transaction import dbconnection
22 from mailman.database.types import SAUnicode
23 from mailman.interfaces.messages import IMessage
24 from public import public
25 from sqlalchemy import Column, Integer
26 from zope.interface import implementer
29 @public
30 @implementer(IMessage)
31 class Message(Model):
32 """A message in the message store."""
34 __tablename__ = 'message'
36 id = Column(Integer, primary_key=True)
37 # This is a Messge-ID field representation, not a database row id.
38 message_id = Column(SAUnicode)
39 message_id_hash = Column(SAUnicode)
40 path = Column(SAUnicode)
42 @dbconnection
43 def __init__(self, store, message_id, message_id_hash, path):
44 super().__init__()
45 self.message_id = message_id
46 self.message_id_hash = message_id_hash
47 self.path = path
48 store.add(self)