diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman/database/mailman.sql | 22 | ||||
| -rw-r--r-- | src/mailman/database/types.py | 24 | ||||
| -rw-r--r-- | src/mailman/docs/NEWS.rst | 2 | ||||
| -rw-r--r-- | src/mailman/interfaces/mailinglist.py | 8 | ||||
| -rw-r--r-- | src/mailman/model/autorespond.py | 4 | ||||
| -rw-r--r-- | src/mailman/model/bounce.py | 2 | ||||
| -rw-r--r-- | src/mailman/model/digests.py | 3 | ||||
| -rw-r--r-- | src/mailman/model/mailinglist.py | 28 | ||||
| -rw-r--r-- | src/mailman/model/member.py | 4 | ||||
| -rw-r--r-- | src/mailman/model/mime.py | 4 | ||||
| -rw-r--r-- | src/mailman/model/preferences.py | 5 | ||||
| -rw-r--r-- | src/mailman/model/requests.py | 2 |
12 files changed, 62 insertions, 46 deletions
diff --git a/src/mailman/database/mailman.sql b/src/mailman/database/mailman.sql index 0a773c28e..a87115335 100644 --- a/src/mailman/database/mailman.sql +++ b/src/mailman/database/mailman.sql @@ -1,7 +1,7 @@ CREATE TABLE _request ( id INTEGER NOT NULL, "key" TEXT, - request_type TEXT, + request_type INTEGER, data_hash TEXT, mailing_list_id INTEGER, PRIMARY KEY (id), @@ -60,7 +60,7 @@ CREATE TABLE bounceevent ( email TEXT, 'timestamp' TIMESTAMP, message_id TEXT, - context TEXT, + context INTEGER, processed BOOLEAN, PRIMARY KEY (id) ); @@ -127,7 +127,7 @@ CREATE TABLE mailinglist ( autoresponse_request_text TEXT, autoresponse_grace_period TEXT, -- Bounces. - forward_unrecognized_bounces_to TEXT, + forward_unrecognized_bounces_to INTEGER, process_bounces BOOLEAN, bounce_info_stale_after TEXT, bounce_matching_headers TEXT, @@ -148,7 +148,7 @@ CREATE TABLE mailinglist ( digest_is_default BOOLEAN, digest_send_periodic BOOLEAN, digest_size_threshold INTEGER, - digest_volume_frequency TEXT, + digest_volume_frequency INTEGER, digestable BOOLEAN, discard_these_nonmembers BLOB, emergency BOOLEAN, @@ -172,20 +172,20 @@ CREATE TABLE mailinglist ( msg_footer TEXT, msg_header TEXT, new_member_options INTEGER, - news_moderation TEXT, + news_moderation INTEGER, news_prefix_subject_too BOOLEAN, nntp_host TEXT, nondigestable BOOLEAN, nonmember_rejection_notice TEXT, obscure_addresses BOOLEAN, - personalize TEXT, + personalize INTEGER, pipeline TEXT, post_id INTEGER, preferred_language TEXT, private_roster BOOLEAN, real_name TEXT, reject_these_nonmembers BLOB, - reply_goes_to_list TEXT, + reply_goes_to_list INTEGER, reply_to_address TEXT, require_explicit_destination BOOLEAN, respond_to_post_requests BOOLEAN, @@ -208,7 +208,7 @@ CREATE TABLE mailinglist ( CREATE TABLE member ( id INTEGER NOT NULL, _member_id TEXT, - role TEXT, + role INTEGER, mailing_list TEXT, moderation_action INTEGER, address_id INTEGER, @@ -238,7 +238,7 @@ CREATE TABLE onelastdigest ( id INTEGER NOT NULL, mailing_list_id INTEGER, address_id INTEGER, - delivery_mode TEXT, + delivery_mode INTEGER, PRIMARY KEY (id), CONSTRAINT onelastdigest_mailing_list_id_fk FOREIGN KEY (mailing_list_id) REFERENCES mailinglist(id), @@ -270,8 +270,8 @@ CREATE TABLE preferences ( preferred_language TEXT, receive_list_copy BOOLEAN, receive_own_postings BOOLEAN, - delivery_mode TEXT, - delivery_status TEXT, + delivery_mode INTEGER, + delivery_status INTEGER, PRIMARY KEY (id) ); diff --git a/src/mailman/database/types.py b/src/mailman/database/types.py index f126cc05a..21333214a 100644 --- a/src/mailman/database/types.py +++ b/src/mailman/database/types.py @@ -29,37 +29,37 @@ __all__ = [ from storm.properties import SimpleProperty from storm.variables import Variable -from mailman.utilities.modules import find_name - class _EnumVariable(Variable): - """Storm variable. + """Storm variable for supporting flufl.enum.Enum types. - To use this, make the database column a TEXT. + To use this, make the database column a INTEGER. """ + def __init__(self, *args, **kws): + self._enum = kws.pop('enum') + super(_EnumVariable, self).__init__(*args, **kws) + def parse_set(self, value, from_db): if value is None: return None if not from_db: return value - path, colon, intvalue = value.rpartition(':') - class_ = find_name(path) - return class_[int(intvalue)] + return self._enum[value] def parse_get(self, value, to_db): if value is None: return None if not to_db: return value - return '{0}.{1}:{2}'.format( - value.enumclass.__module__, - value.enumclass.__name__, - int(value)) + return int(value) class Enum(SimpleProperty): - """Custom Enum type for Storm.""" + """Custom Enum type for Storm supporting flufl.enum.Enums.""" variable_class = _EnumVariable + + def __init__(self, enum=None): + super(Enum, self).__init__(enum=enum) diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst index a81bff574..84b19433a 100644 --- a/src/mailman/docs/NEWS.rst +++ b/src/mailman/docs/NEWS.rst @@ -35,6 +35,8 @@ Architecture are deleted. (LP: #837526) * IDomain.email_host -> .mail_host (LP: #831660) * User and Member ids are now proper UUIDs. + * Improved the way enums are stored in the database, so that they are more + explicitly expressed in the code, and more database efficient. REST ---- diff --git a/src/mailman/interfaces/mailinglist.py b/src/mailman/interfaces/mailinglist.py index c08e257c1..4ef35c115 100644 --- a/src/mailman/interfaces/mailinglist.py +++ b/src/mailman/interfaces/mailinglist.py @@ -253,7 +253,7 @@ class IMailingList(Interface): preferred address that is explicitly subscribed with the same role. """ - # Posting history. + # Delivery. last_post_at = Attribute( """The date and time a message was last posted to the mailing list.""") @@ -262,6 +262,12 @@ class IMailingList(Interface): """A monotonically increasing integer sequentially assigned to each list posting.""") + personalize = Attribute( + """The type of personalization that is applied to postings.""") + + reply_goes_to_list = Attribute( + """Reply-To: header munging policy.""") + # Digests. digest_last_sent_at = Attribute( diff --git a/src/mailman/model/autorespond.py b/src/mailman/model/autorespond.py index 8097fb013..8fb2ca937 100644 --- a/src/mailman/model/autorespond.py +++ b/src/mailman/model/autorespond.py @@ -33,7 +33,7 @@ from mailman.config import config from mailman.database.model import Model from mailman.database.types import Enum from mailman.interfaces.autorespond import ( - IAutoResponseRecord, IAutoResponseSet) + IAutoResponseRecord, IAutoResponseSet, Response) from mailman.utilities.datetime import today @@ -49,7 +49,7 @@ class AutoResponseRecord(Model): mailing_list_id = Int() mailing_list = Reference(mailing_list_id, 'MailingList.id') - response_type = Enum() + response_type = Enum(Response) date_sent = Date() def __init__(self, mailing_list, address, response_type): diff --git a/src/mailman/model/bounce.py b/src/mailman/model/bounce.py index 20953b0ff..eaeaf33bf 100644 --- a/src/mailman/model/bounce.py +++ b/src/mailman/model/bounce.py @@ -46,7 +46,7 @@ class BounceEvent(Model): email = Unicode() timestamp = DateTime() message_id = Unicode() - context = Enum() + context = Enum(BounceContext) processed = Bool() def __init__(self, list_name, email, msg, context=None): diff --git a/src/mailman/model/digests.py b/src/mailman/model/digests.py index ded0fe44f..d24b946ed 100644 --- a/src/mailman/model/digests.py +++ b/src/mailman/model/digests.py @@ -31,6 +31,7 @@ from zope.interface import implements from mailman.database.model import Model from mailman.database.types import Enum from mailman.interfaces.digests import IOneLastDigest +from mailman.interfaces.member import DeliveryMode @@ -45,7 +46,7 @@ class OneLastDigest(Model): address_id = Int() address = Reference(address_id, 'Address.id') - delivery_mode = Enum() + delivery_mode = Enum(DeliveryMode) def __init__(self, mailing_list, address, delivery_mode): self.mailing_list = mailing_list diff --git a/src/mailman/model/mailinglist.py b/src/mailman/model/mailinglist.py index fe5355806..9a332f48b 100644 --- a/src/mailman/model/mailinglist.py +++ b/src/mailman/model/mailinglist.py @@ -38,14 +38,20 @@ from zope.interface import implements from mailman.config import config from mailman.database.model import Model from mailman.database.types import Enum +from mailman.interfaces.action import Action from mailman.interfaces.address import IAddress +from mailman.interfaces.autorespond import ResponseAction +from mailman.interfaces.bounce import UnrecognizedBounceDisposition +from mailman.interfaces.digests import DigestFrequency from mailman.interfaces.domain import IDomainManager from mailman.interfaces.languages import ILanguageManager from mailman.interfaces.mailinglist import ( - IAcceptableAlias, IAcceptableAliasSet, IMailingList, Personalization) + IAcceptableAlias, IAcceptableAliasSet, IMailingList, Personalization, + ReplyToMunging) from mailman.interfaces.member import ( AlreadySubscribedError, MemberRole, MissingPreferredAddressError) from mailman.interfaces.mime import FilterType +from mailman.interfaces.nntp import NewsModeration from mailman.interfaces.user import IUser from mailman.model import roster from mailman.model.digests import OneLastDigest @@ -103,11 +109,11 @@ class MailingList(Model): archive_volume_frequency = Int() # XXX # Automatic responses. autoresponse_grace_period = TimeDelta() - autorespond_owner = Enum() + autorespond_owner = Enum(ResponseAction) autoresponse_owner_text = Unicode() - autorespond_postings = Enum() + autorespond_postings = Enum(ResponseAction) autoresponse_postings_text = Unicode() - autorespond_requests = Enum() + autorespond_requests = Enum(ResponseAction) autoresponse_request_text = Unicode() # Content filters. filter_content = Bool() @@ -121,18 +127,18 @@ class MailingList(Model): 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() + forward_unrecognized_bounces_to = Enum(UnrecognizedBounceDisposition) process_bounces = Bool() # Miscellaneous - default_member_action = Enum() - default_nonmember_action = Enum() + default_member_action = Enum(Action) + default_nonmember_action = Enum(Action) description = Unicode() digest_footer = Unicode() digest_header = Unicode() digest_is_default = Bool() digest_send_periodic = Bool() digest_size_threshold = Float() - digest_volume_frequency = Enum() + digest_volume_frequency = Enum(DigestFrequency) digestable = Bool() discard_these_nonmembers = Pickle() emergency = Bool() @@ -156,20 +162,20 @@ class MailingList(Model): msg_footer = Unicode() msg_header = Unicode() new_member_options = Int() - news_moderation = Enum() + news_moderation = Enum(NewsModeration) news_prefix_subject_too = Bool() nntp_host = Unicode() nondigestable = Bool() nonmember_rejection_notice = Unicode() obscure_addresses = Bool() - personalize = Enum() + personalize = Enum(Personalization) pipeline = Unicode() post_id = Int() _preferred_language = Unicode(name='preferred_language') private_roster = Bool() real_name = Unicode() reject_these_nonmembers = Pickle() - reply_goes_to_list = Enum() + reply_goes_to_list = Enum(ReplyToMunging) reply_to_address = Unicode() require_explicit_destination = Bool() respond_to_post_requests = Bool() diff --git a/src/mailman/model/member.py b/src/mailman/model/member.py index c7e9713dd..f8168fc92 100644 --- a/src/mailman/model/member.py +++ b/src/mailman/model/member.py @@ -51,9 +51,9 @@ class Member(Model): id = Int(primary=True) _member_id = UUID() - role = Enum() + role = Enum(MemberRole) mailing_list = Unicode() - moderation_action = Enum() + moderation_action = Enum(Action) address_id = Int() _address = Reference(address_id, 'Address.id') diff --git a/src/mailman/model/mime.py b/src/mailman/model/mime.py index 8ba9adf39..fee8a6184 100644 --- a/src/mailman/model/mime.py +++ b/src/mailman/model/mime.py @@ -30,7 +30,7 @@ from zope.interface import implements from mailman.database.model import Model from mailman.database.types import Enum -from mailman.interfaces.mime import IContentFilter +from mailman.interfaces.mime import IContentFilter, FilterType @@ -43,7 +43,7 @@ class ContentFilter(Model): mailing_list_id = Int() mailing_list = Reference(mailing_list_id, 'MailingList.id') - filter_type = Enum() + filter_type = Enum(FilterType) filter_pattern = Unicode() def __init__(self, mailing_list, filter_pattern, filter_type): diff --git a/src/mailman/model/preferences.py b/src/mailman/model/preferences.py index a874bc398..ca96e137b 100644 --- a/src/mailman/model/preferences.py +++ b/src/mailman/model/preferences.py @@ -32,6 +32,7 @@ from zope.interface import implements from mailman.database.model import Model from mailman.database.types import Enum from mailman.interfaces.languages import ILanguageManager +from mailman.interfaces.member import DeliveryMode, DeliveryStatus from mailman.interfaces.preferences import IPreferences @@ -45,8 +46,8 @@ class Preferences(Model): _preferred_language = Unicode(name='preferred_language') receive_list_copy = Bool() receive_own_postings = Bool() - delivery_mode = Enum() - delivery_status = Enum() + delivery_mode = Enum(DeliveryMode) + delivery_status = Enum(DeliveryStatus) def __repr__(self): return '<Preferences object at {0:#x}>'.format(id(self)) diff --git a/src/mailman/model/requests.py b/src/mailman/model/requests.py index e1db9e63f..20ded6534 100644 --- a/src/mailman/model/requests.py +++ b/src/mailman/model/requests.py @@ -126,7 +126,7 @@ class _Request(Model): id = Int(primary=True, default=AutoReload) key = Unicode() - request_type = Enum() + request_type = Enum(RequestType) data_hash = RawStr() mailing_list_id = Int() |
