summaryrefslogtreecommitdiff
path: root/src/mailman/model/autorespond.py
diff options
context:
space:
mode:
authorBarry Warsaw2012-07-06 21:08:41 -0400
committerBarry Warsaw2012-07-06 21:08:41 -0400
commit8d8ab1655b51e277570005b445d3b014afcfbc57 (patch)
tree6ba0147d975636e129a787c9dfa64dae8cffae89 /src/mailman/model/autorespond.py
parentcd3f84b301c2150fea5402129a2e7bc862fbb52b (diff)
parent01415190ab44e69a8f09a6411564a7cb288404e8 (diff)
downloadmailman-8d8ab1655b51e277570005b445d3b014afcfbc57.tar.gz
mailman-8d8ab1655b51e277570005b445d3b014afcfbc57.tar.zst
mailman-8d8ab1655b51e277570005b445d3b014afcfbc57.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())