summaryrefslogtreecommitdiff
path: root/src/mailman/database
diff options
context:
space:
mode:
authorBarry Warsaw2009-05-16 11:08:46 -0400
committerBarry Warsaw2009-05-16 11:08:46 -0400
commit7e23b2f358806cb14b92dc7833ce773738534d41 (patch)
tree5499b536a163ebb4dedab62f4f7a97b460cece18 /src/mailman/database
parentad07de3dcdbf0ef11b5b324b9521b748da207fc7 (diff)
downloadmailman-7e23b2f358806cb14b92dc7833ce773738534d41.tar.gz
mailman-7e23b2f358806cb14b92dc7833ce773738534d41.tar.zst
mailman-7e23b2f358806cb14b92dc7833ce773738534d41.zip
Refactor __import__'s into a separate utility module.
Diffstat (limited to 'src/mailman/database')
-rw-r--r--src/mailman/database/pending.py8
-rw-r--r--src/mailman/database/types.py8
2 files changed, 7 insertions, 9 deletions
diff --git a/src/mailman/database/pending.py b/src/mailman/database/pending.py
index 9c2da9064..2a0e5d09e 100644
--- a/src/mailman/database/pending.py
+++ b/src/mailman/database/pending.py
@@ -40,6 +40,7 @@ from mailman.config import config
from mailman.database.model import Model
from mailman.interfaces.pending import (
IPendable, IPended, IPendedKeyValue, IPendings)
+from mailman.utilities.modules import call_name
@@ -145,11 +146,8 @@ class Pendings:
for keyvalue in store.find(PendedKeyValue,
PendedKeyValue.pended_id == pending.id):
if keyvalue.value is not None and '\1' in keyvalue.value:
- typename, value = keyvalue.value.split('\1', 1)
- package, dot, classname = typename.rpartition('.')
- __import__(package)
- module = sys.modules[package]
- pendable[keyvalue.key] = getattr(module, classname)(value)
+ type_name, value = keyvalue.value.split('\1', 1)
+ pendable[keyvalue.key] = call_name(type_name, value)
else:
pendable[keyvalue.key] = keyvalue.value
if expunge:
diff --git a/src/mailman/database/types.py b/src/mailman/database/types.py
index 4b3031c3b..f559737e2 100644
--- a/src/mailman/database/types.py
+++ b/src/mailman/database/types.py
@@ -31,6 +31,8 @@ import sys
from storm.properties import SimpleProperty
from storm.variables import Variable
+from mailman.utilities.modules import find_name
+
class _EnumVariable(Variable):
@@ -42,10 +44,8 @@ class _EnumVariable(Variable):
if not from_db:
return value
path, colon, intvalue = value.rpartition(':')
- package, dot, classname = path.rpartition('.')
- __import__(package)
- cls = getattr(sys.modules[package], classname)
- return cls[int(intvalue)]
+ class_ = find_name(path)
+ return class_[int(intvalue)]
def parse_get(self, value, to_db):
if value is None: