diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman/database/model.py | 5 | ||||
| -rw-r--r-- | src/mailman/model/address.py | 22 | ||||
| -rw-r--r-- | src/mailman/model/autorespond.py | 12 | ||||
| -rw-r--r-- | src/mailman/model/bans.py | 8 | ||||
| -rw-r--r-- | src/mailman/model/bounce.py | 11 | ||||
| -rw-r--r-- | src/mailman/model/digests.py | 11 | ||||
| -rw-r--r-- | src/mailman/model/domain.py | 11 | ||||
| -rw-r--r-- | src/mailman/model/language.py | 5 | ||||
| -rw-r--r-- | src/mailman/model/mailinglist.py | 207 |
9 files changed, 151 insertions, 141 deletions
diff --git a/src/mailman/database/model.py b/src/mailman/database/model.py index ba2d39213..5fbf4005d 100644 --- a/src/mailman/database/model.py +++ b/src/mailman/database/model.py @@ -27,9 +27,12 @@ __all__ = [ from operator import attrgetter +from sqlalchemy.ext.declarative import declarative_base from storm.properties import PropertyPublisherMeta +Base = declerative_base() + class ModelMeta(PropertyPublisherMeta): """Do more magic on table classes.""" @@ -65,4 +68,4 @@ class ModelMeta(PropertyPublisherMeta): class Model: """Like Storm's `Storm` subclass, but with a bit extra.""" - __metaclass__ = ModelMeta + __metaclass__ = Base diff --git a/src/mailman/model/address.py b/src/mailman/model/address.py index f69679210..636193547 100644 --- a/src/mailman/model/address.py +++ b/src/mailman/model/address.py @@ -27,6 +27,8 @@ __all__ = [ from email.utils import formataddr from storm.locals import DateTime, Int, Reference, Unicode +from sqlalchemy import (Column, Integer, String, Unicode, + ForeignKey, Datetime) from zope.component import getUtility from zope.event import notify from zope.interface import implementer @@ -42,20 +44,18 @@ from mailman.utilities.datetime import now class Address(Model): """See `IAddress`.""" - id = Int(primary=True) - email = Unicode() - _original = Unicode() - display_name = Unicode() - _verified_on = DateTime(name='verified_on') - registered_on = DateTime() + id = Column(Integer, primary_key=True) + email = Column(Unicode) + _original = Column(Unicode) + display_name = Column(Unicode) + _verified_on = Column('verified_on', Datetime) + registered_on = Column(DateTime) + + user = Column(Integer, ForeignKey('user.id')) + preferences = Column(Integer, ForeignKey('preferences.id')) - user_id = Int() - user = Reference(user_id, 'User.id') - preferences_id = Int() - preferences = Reference(preferences_id, 'Preferences.id') def __init__(self, email, display_name): - super(Address, self).__init__() getUtility(IEmailValidator).validate(email) lower_case = email.lower() self.email = lower_case diff --git a/src/mailman/model/autorespond.py b/src/mailman/model/autorespond.py index c5e736613..cc66a3516 100644 --- a/src/mailman/model/autorespond.py +++ b/src/mailman/model/autorespond.py @@ -26,6 +26,8 @@ __all__ = [ ] +from sqlalchemy import (Column, Integer, String, Unicode, + ForeignKey, Date) from storm.locals import And, Date, Desc, Int, Reference from zope.interface import implementer @@ -42,16 +44,14 @@ from mailman.utilities.datetime import today class AutoResponseRecord(Model): """See `IAutoResponseRecord`.""" - id = Int(primary=True) + id = Column(Integer, primary_key=True) - address_id = Int() - address = Reference(address_id, 'Address.id') + address_id = Column(Integer, ForeignKey('address.id')) - mailing_list_id = Int() - mailing_list = Reference(mailing_list_id, 'MailingList.id') + mailing_list_id = Column(Integer, ForeignKey('mailinglist.id')) response_type = Enum(Response) - date_sent = Date() + date_sent = Column(Date) def __init__(self, mailing_list, address, response_type): self.mailing_list = mailing_list diff --git a/src/mailman/model/bans.py b/src/mailman/model/bans.py index 673e8e0c1..3e0683e8a 100644 --- a/src/mailman/model/bans.py +++ b/src/mailman/model/bans.py @@ -29,7 +29,7 @@ import re from storm.locals import Int, Unicode from zope.interface import implementer - +from sqlalchemy import Column, Integer, Unicode from mailman.database.model import Model from mailman.database.transaction import dbconnection from mailman.interfaces.bans import IBan, IBanManager @@ -40,9 +40,9 @@ from mailman.interfaces.bans import IBan, IBanManager class Ban(Model): """See `IBan`.""" - id = Int(primary=True) - email = Unicode() - list_id = Unicode() + id = Column(Integer, primary_key=True) + email = Column(Unicode) + list_id = Column(Unicode) def __init__(self, email, list_id): super(Ban, self).__init__() diff --git a/src/mailman/model/bounce.py b/src/mailman/model/bounce.py index 134c51263..e852daa1d 100644 --- a/src/mailman/model/bounce.py +++ b/src/mailman/model/bounce.py @@ -28,6 +28,7 @@ __all__ = [ from storm.locals import Bool, Int, DateTime, Unicode from zope.interface import implementer +from sqlalchemy import Column, Integer, Unicode, DateTime, Boolean from mailman.database.model import Model from mailman.database.transaction import dbconnection @@ -42,13 +43,13 @@ from mailman.utilities.datetime import now class BounceEvent(Model): """See `IBounceEvent`.""" - id = Int(primary=True) - list_id = Unicode() - email = Unicode() + id = Unicode(Integer, primary_key=True) + list_id = Column(Unicode) + email = Column(Unicode) timestamp = DateTime() - message_id = Unicode() + message_id = Column(Unicode) context = Enum(BounceContext) - processed = Bool() + processed = COlumn(Boolean) def __init__(self, list_id, email, msg, context=None): self.list_id = list_id diff --git a/src/mailman/model/digests.py b/src/mailman/model/digests.py index 5d9f3ddd1..77e0a0663 100644 --- a/src/mailman/model/digests.py +++ b/src/mailman/model/digests.py @@ -27,6 +27,7 @@ __all__ = [ from storm.locals import Int, Reference from zope.interface import implementer +from sqlalchemy import Column, Integer, ForeignKey from mailman.database.model import Model from mailman.database.types import Enum @@ -39,13 +40,13 @@ from mailman.interfaces.member import DeliveryMode class OneLastDigest(Model): """See `IOneLastDigest`.""" - id = Int(primary=True) + id = Column(Integer, primary_key=True) - mailing_list_id = Int() - mailing_list = Reference(mailing_list_id, 'MailingList.id') + mailing_list_id = Column(Integer, ForeignKey('mailinglist.id')) + #mailing_list = Reference(mailing_list_id, 'MailingList.id') - address_id = Int() - address = Reference(address_id, 'Address.id') + address_id = Columne(Integer, ForeignKey('address.id')) + #address = Reference(address_id, 'Address.id') delivery_mode = Enum(DeliveryMode) diff --git a/src/mailman/model/domain.py b/src/mailman/model/domain.py index 28e346022..cd974438c 100644 --- a/src/mailman/model/domain.py +++ b/src/mailman/model/domain.py @@ -27,6 +27,7 @@ __all__ = [ from urlparse import urljoin, urlparse +from sqlalchemy import Column, Unicode, Integer from storm.locals import Int, Unicode from zope.event import notify from zope.interface import implementer @@ -44,12 +45,12 @@ from mailman.model.mailinglist import MailingList class Domain(Model): """Domains.""" - id = Int(primary=True) + id = Column(Integer, primary_key=True) - mail_host = Unicode() - base_url = Unicode() - description = Unicode() - contact_address = Unicode() + mail_host = Column(Unicode) + base_url = Column(Unicode) + description = Column(Unicode) + contact_address = Column(Unicode) def __init__(self, mail_host, description=None, diff --git a/src/mailman/model/language.py b/src/mailman/model/language.py index 14cf53f07..5d5e538ab 100644 --- a/src/mailman/model/language.py +++ b/src/mailman/model/language.py @@ -27,6 +27,7 @@ __all__ = [ from storm.locals import Int, Unicode from zope.interface import implementer +from sqlalchemy import Column, Unicode, Integer from mailman.database import Model from mailman.interfaces import ILanguage @@ -37,5 +38,5 @@ from mailman.interfaces import ILanguage class Language(Model): """See `ILanguage`.""" - id = Int(primary=True) - code = Unicode() + id = Column(Integer, primary_key=True) + code = Column(Unicode) diff --git a/src/mailman/model/mailinglist.py b/src/mailman/model/mailinglist.py index 955a76968..c6f58b8f2 100644 --- a/src/mailman/model/mailinglist.py +++ b/src/mailman/model/mailinglist.py @@ -29,7 +29,10 @@ import os from storm.locals import ( And, Bool, DateTime, Float, Int, Pickle, RawStr, Reference, Store, - TimeDelta, Unicode) + TimeDelta, Unicode, Enum) +from sqlalchemy import ( Boolean, DateTime, Float, Integer, Unicode + PickleType, Interval) + from urlparse import urljoin from zope.component import getUtility from zope.event import notify @@ -73,121 +76,121 @@ UNDERSCORE = '_' class MailingList(Model): """See `IMailingList`.""" - id = Int(primary=True) + id = Column(Integer, primary_key=True) # XXX denotes attributes that should be part of the public interface but # are currently missing. # List identity - list_name = Unicode() - mail_host = Unicode() - _list_id = Unicode(name='list_id') - allow_list_posts = Bool() - include_rfc2369_headers = Bool() - advertised = Bool() - anonymous_list = Bool() + list_name = Column(Unicode) + mail_host = Column(Unicode) + _list_id = Column('list_id', Unicode) + allow_list_posts = Column(Boolean) + include_rfc2369_headers = Column(Boolean) + advertised = Column(Boolean) + anonymous_list = Column(Boolean) # Attributes not directly modifiable via the web u/i - created_at = DateTime() + created_at = Column(DateTime) # Attributes which are directly modifiable via the web u/i. The more # complicated attributes are currently stored as pickles, though that # will change as the schema and implementation is developed. - next_request_id = Int() - next_digest_number = Int() - digest_last_sent_at = DateTime() - volume = Int() - last_post_at = DateTime() + next_request_id = Column(Integer) + next_digest_number = Column(Integer) + digest_last_sent_at = Column(DateTime) + volume = Column(Integer) + last_post_at = Column(DateTime) # Implicit destination. - acceptable_aliases_id = Int() - acceptable_alias = Reference(acceptable_aliases_id, 'AcceptableAlias.id') + acceptable_aliases_id = Column(Integer, ForeignKey('acceptablealias.id')) + # acceptable_alias = Reference(acceptable_aliases_id, 'AcceptableAlias.id') # Attributes which are directly modifiable via the web u/i. The more # complicated attributes are currently stored as pickles, though that # will change as the schema and implementation is developed. - accept_these_nonmembers = Pickle() # XXX - admin_immed_notify = Bool() - admin_notify_mchanges = Bool() - administrivia = Bool() - archive_policy = Enum(ArchivePolicy) + accept_these_nonmembers = Column(PickleType) # XXX + admin_immed_notify = Column(Boolean) + admin_notify_mchanges = Column(Boolean) + administrivia = Column(Boolean) + archive_policy = Column(Enum(ArchivePolicy) # Automatic responses. - autoresponse_grace_period = TimeDelta() - autorespond_owner = Enum(ResponseAction) - autoresponse_owner_text = Unicode() - autorespond_postings = Enum(ResponseAction) - autoresponse_postings_text = Unicode() - autorespond_requests = Enum(ResponseAction) - autoresponse_request_text = Unicode() + autoresponse_grace_period = Column(Interval) + autorespond_owner = Column(Enum(ResponseAction)) + autoresponse_owner_text = Column(Unicode) + autorespond_postings = Column(Enum(ResponseAction)) + autoresponse_postings_text = Column(Unicode) + autorespond_requests = Column(Enum(ResponseAction)) + autoresponse_request_text = Column(Unicode) # Content filters. - filter_action = Enum(FilterAction) - filter_content = Bool() - collapse_alternatives = Bool() - convert_html_to_plaintext = Bool() + filter_action = Column(Enum(FilterAction)) + filter_content = Column(Boolean) + collapse_alternatives = Column(Boolean) + convert_html_to_plaintext = Column(Boolean) # Bounces. - bounce_info_stale_after = TimeDelta() # XXX - bounce_matching_headers = Unicode() # XXX - bounce_notify_owner_on_disable = Bool() # XXX - bounce_notify_owner_on_removal = Bool() # XXX - bounce_score_threshold = Int() # XXX - bounce_you_are_disabled_warnings = Int() # XXX - bounce_you_are_disabled_warnings_interval = TimeDelta() # XXX - forward_unrecognized_bounces_to = Enum(UnrecognizedBounceDisposition) - process_bounces = Bool() + bounce_info_stale_after = Column(Interval) # XXX + bounce_matching_headers = Column(Unicode) # XXX + bounce_notify_owner_on_disable = Column(Boolean) # XXX + bounce_notify_owner_on_removal = Column(Boolean) # XXX + bounce_score_threshold = Column(Integer) # XXX + bounce_you_are_disabled_warnings = Column(Integer) # XXX + bounce_you_are_disabled_warnings_interval = Column(Interval) # XXX + forward_unrecognized_bounces_to = Column(Enum(UnrecognizedBounceDisposition)) + process_bounces = Column(Boolean) # Miscellaneous - default_member_action = Enum(Action) - default_nonmember_action = Enum(Action) - description = Unicode() - digest_footer_uri = Unicode() - digest_header_uri = Unicode() - digest_is_default = Bool() - digest_send_periodic = Bool() - digest_size_threshold = Float() - digest_volume_frequency = Enum(DigestFrequency) - digestable = Bool() - discard_these_nonmembers = Pickle() - emergency = Bool() - encode_ascii_prefixes = Bool() - first_strip_reply_to = Bool() - footer_uri = Unicode() - forward_auto_discards = Bool() - gateway_to_mail = Bool() - gateway_to_news = Bool() - goodbye_message_uri = Unicode() - header_matches = Pickle() - header_uri = Unicode() - hold_these_nonmembers = Pickle() - info = Unicode() - linked_newsgroup = Unicode() - max_days_to_hold = Int() - max_message_size = Int() - max_num_recipients = Int() - member_moderation_notice = Unicode() - mime_is_default_digest = Bool() + default_member_action = Column(Enum(Action)) + default_nonmember_action = Column(Enum(Action)) + description = Column(Unicode) + digest_footer_uri = Column(Unicode) + digest_header_uri = Column(Unicode) + digest_is_default = Column(Boolean) + digest_send_periodic = Column(Boolean) + digest_size_threshold = Column(Float) + digest_volume_frequency = Column(Enum(DigestFrequency)) + digestable = Column(Boolean) + discard_these_nonmembers = Column(PickleType) + emergency = Column(Boolean) + encode_ascii_prefixes = Column(Boolean) + first_strip_reply_to = Column(Boolean) + footer_uri = Column(Unicode) + forward_auto_discards = Column(Boolean) + gateway_to_mail = Column(Boolean) + gateway_to_news = Column(Boolean) + goodbye_message_uri = Column(Unicode) + header_matches = Column(PickleType) + header_uri = Column(Unicode) + hold_these_nonmembers = Column(PickleType) + info = Column(Unicode) + linked_newsgroup = Column(Unicode) + max_days_to_hold = Column(Integer) + max_message_size = Column(Integer) + max_num_recipients = Column(Integer) + member_moderation_notice = Column(Unicode) + mime_is_default_digest = Column(Boolean) # FIXME: There should be no moderator_password moderator_password = RawStr() - newsgroup_moderation = Enum(NewsgroupModeration) - nntp_prefix_subject_too = Bool() - nondigestable = Bool() - nonmember_rejection_notice = Unicode() - obscure_addresses = Bool() - owner_chain = Unicode() - owner_pipeline = Unicode() - personalize = Enum(Personalization) - post_id = Int() - posting_chain = Unicode() - posting_pipeline = Unicode() - _preferred_language = Unicode(name='preferred_language') - display_name = Unicode() - reject_these_nonmembers = Pickle() - reply_goes_to_list = Enum(ReplyToMunging) - reply_to_address = Unicode() - require_explicit_destination = Bool() - respond_to_post_requests = Bool() - scrub_nondigest = Bool() - send_goodbye_message = Bool() - send_welcome_message = Bool() - subject_prefix = Unicode() - topics = Pickle() - topics_bodylines_limit = Int() - topics_enabled = Bool() - welcome_message_uri = Unicode() + newsgroup_moderation = Column(Enum(NewsgroupModeration)) + nntp_prefix_subject_too = Column(Boolean) + nondigestable = Column(Boolean) + nonmember_rejection_notice = Column(Unicode) + obscure_addresses = Column(Boolean) + owner_chain = Column(Unicode) + owner_pipeline = Column(Unicode) + personalize = Column(Enum(Personalization)) + post_id = Column(Integer) + posting_chain = Column(Unicode) + posting_pipeline = Column(Unicode) + _preferred_language = Column('preferred_language', Unicode) + display_name = Column(Unicode) + reject_these_nonmembers = Column(PickleType) + reply_goes_to_list = Column(Enum(ReplyToMunging)) + reply_to_address = Column(Unicode) + require_explicit_destination = Column(Boolean) + respond_to_post_requests = Column(Boolean) + scrub_nondigest = Column(Boolean) + send_goodbye_message = Column(Boolean) + send_welcome_message = Column(Boolean) + subject_prefix = Column(Unicode) + topics = Column(PickleType) + topics_bodylines_limit = Column(Integer) + topics_enabled = Column(Boolean) + welcome_message_uri = Column(Unicode) def __init__(self, fqdn_listname): super(MailingList, self).__init__() @@ -496,10 +499,10 @@ class AcceptableAlias(Model): id = Int(primary=True) - mailing_list_id = Int() + mailing_list_id = Column(Integer) mailing_list = Reference(mailing_list_id, MailingList.id) - alias = Unicode() + alias = Column(Unicode) def __init__(self, mailing_list, alias): self.mailing_list = mailing_list @@ -548,10 +551,10 @@ class ListArchiver(Model): id = Int(primary=True) - mailing_list_id = Int() + mailing_list_id = Column(Integer) mailing_list = Reference(mailing_list_id, MailingList.id) - name = Unicode() - _is_enabled = Bool() + name = Column(Unicode) + _is_enabled = Column(Boolean) def __init__(self, mailing_list, archiver_name, system_archiver): self.mailing_list = mailing_list |
