summaryrefslogtreecommitdiff
path: root/src/mailman/database
diff options
context:
space:
mode:
authorBarry Warsaw2011-09-23 19:47:19 -0400
committerBarry Warsaw2011-09-23 19:47:19 -0400
commitff79580cef42838a45c0717e32ac0831601c7459 (patch)
tree718a2f4d8b3d407f9a4cf820e0a707773d79beb4 /src/mailman/database
parent416db276612ac6338524ce350e3b87216ffaffb7 (diff)
downloadmailman-ff79580cef42838a45c0717e32ac0831601c7459.tar.gz
mailman-ff79580cef42838a45c0717e32ac0831601c7459.tar.zst
mailman-ff79580cef42838a45c0717e32ac0831601c7459.zip
Improved the way flufl.enum.Enums are stored in the database. Now, they
should always be stored as INTEGER columns, with the enum class explicitly described in the code. This should be more efficient, and besides EIBTI. Also, filled in a few additional IMailingList attributes which were not documented in the interface.
Diffstat (limited to 'src/mailman/database')
-rw-r--r--src/mailman/database/mailman.sql22
-rw-r--r--src/mailman/database/types.py24
2 files changed, 23 insertions, 23 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)