summaryrefslogtreecommitdiff
path: root/src/mailman/model/autorespond.py
diff options
context:
space:
mode:
authorBarry Warsaw2012-06-03 13:21:38 -0400
committerBarry Warsaw2012-06-03 13:21:38 -0400
commite1aa901fbdcc6d7fbb495a1d9ca1a5079008164a (patch)
tree9146fed874216bfb88707848568d7598ec2e8522 /src/mailman/model/autorespond.py
parent847409ba333375bd9c168e28f15748e58970404f (diff)
parent3c8a07fc76176a8ea89ee6b73aef571d0b2c81ed (diff)
downloadmailman-e1aa901fbdcc6d7fbb495a1d9ca1a5079008164a.tar.gz
mailman-e1aa901fbdcc6d7fbb495a1d9ca1a5079008164a.tar.zst
mailman-e1aa901fbdcc6d7fbb495a1d9ca1a5079008164a.zip
Diffstat (limited to 'src/mailman/model/autorespond.py')
-rw-r--r--src/mailman/model/autorespond.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/mailman/model/autorespond.py b/src/mailman/model/autorespond.py
index 7b42205b4..567dcd19e 100644
--- a/src/mailman/model/autorespond.py
+++ b/src/mailman/model/autorespond.py
@@ -17,7 +17,7 @@
"""Module stuff."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -27,10 +27,10 @@ __all__ = [
from storm.locals import And, Date, Desc, Int, Reference
-from zope.interface import implements
+from zope.interface import implementer
-from mailman.config import config
from mailman.database.model import Model
+from mailman.database.transaction import dbconnection
from mailman.database.types import Enum
from mailman.interfaces.autorespond import (
IAutoResponseRecord, IAutoResponseSet, Response)
@@ -38,8 +38,9 @@ from mailman.utilities.datetime import today
+@implementer(IAutoResponseRecord)
class AutoResponseRecord(Model):
- implements(IAutoResponseRecord)
+ """See `IAutoResponseRecord`."""
id = Int(primary=True)
@@ -60,33 +61,37 @@ class AutoResponseRecord(Model):
+@implementer(IAutoResponseSet)
class AutoResponseSet:
- implements(IAutoResponseSet)
+ """See `IAutoResponseSet`."""
def __init__(self, mailing_list):
self._mailing_list = mailing_list
- def todays_count(self, address, response_type):
+ @dbconnection
+ def todays_count(self, store, address, response_type):
"""See `IAutoResponseSet`."""
- return config.db.store.find(
+ return store.find(
AutoResponseRecord,
And(AutoResponseRecord.address == address,
AutoResponseRecord.mailing_list == self._mailing_list,
AutoResponseRecord.response_type == response_type,
AutoResponseRecord.date_sent == today())).count()
- def response_sent(self, address, response_type):
+ @dbconnection
+ def response_sent(self, store, address, response_type):
"""See `IAutoResponseSet`."""
response = AutoResponseRecord(
self._mailing_list, address, response_type)
- config.db.store.add(response)
+ store.add(response)
- def last_response(self, address, response_type):
+ @dbconnection
+ def last_response(self, store, address, response_type):
"""See `IAutoResponseSet`."""
- results = config.db.store.find(
+ results = store.find(
AutoResponseRecord,
And(AutoResponseRecord.address == address,
AutoResponseRecord.mailing_list == self._mailing_list,
AutoResponseRecord.response_type == response_type)
- ).order_by(Desc(AutoResponseRecord.date_sent))
+ ).order_by(Desc(AutoResponseRecord.date_sent))
return (None if results.count() == 0 else results.first())