~sambuddhabasu1/mailman/fix_mailman_run_error

« back to all changes in this revision

Viewing changes to src/mailman/model/address.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:
26
26
 
27
27
 
28
28
from email.utils import formataddr
29
 
from storm.locals import DateTime, Int, Reference, Unicode
 
29
from sqlalchemy import Column, DateTime, ForeignKey, Integer, Unicode
 
30
from sqlalchemy.orm import relationship, backref
30
31
from zope.component import getUtility
31
32
from zope.event import notify
32
33
from zope.interface import implementer
42
43
class Address(Model):
43
44
    """See `IAddress`."""
44
45
 
45
 
    id = Int(primary=True)
46
 
    email = Unicode()
47
 
    _original = Unicode()
48
 
    display_name = Unicode()
49
 
    _verified_on = DateTime(name='verified_on')
50
 
    registered_on = DateTime()
51
 
 
52
 
    user_id = Int()
53
 
    user = Reference(user_id, 'User.id')
54
 
    preferences_id = Int()
55
 
    preferences = Reference(preferences_id, 'Preferences.id')
 
46
    __tablename__ = 'address'
 
47
 
 
48
    id = Column(Integer, primary_key=True)
 
49
    email = Column(Unicode)
 
50
    _original = Column(Unicode)
 
51
    display_name = Column(Unicode)
 
52
    _verified_on = Column('verified_on', DateTime)
 
53
    registered_on = Column(DateTime)
 
54
 
 
55
    user_id = Column(Integer, ForeignKey('user.id'), index=True)
 
56
 
 
57
    preferences_id = Column(Integer, ForeignKey('preferences.id'), index=True)
 
58
    preferences = relationship(
 
59
        'Preferences', backref=backref('address', uselist=False))
56
60
 
57
61
    def __init__(self, email, display_name):
58
62
        super(Address, self).__init__()