summaryrefslogtreecommitdiff
path: root/src/mailman/database/types.py
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/types.py
parent416db276612ac6338524ce350e3b87216ffaffb7 (diff)
downloadmailman-ff79580cef42838a45c0717e32ac0831601c7459.tar.gz
mailman-ff79580cef42838a45c0717e32ac0831601c7459.tar.zst
mailman-ff79580cef42838a45c0717e32ac0831601c7459.zip
Diffstat (limited to 'src/mailman/database/types.py')
-rw-r--r--src/mailman/database/types.py24
1 files changed, 12 insertions, 12 deletions
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)