------------------------------------------------------------
revno: 6693
committer: Barry Warsaw <[email protected]>
branch nick: hacking
timestamp: Thu 2009-02-19 00:18:35 -0500
message:
  Add IAutoResponseSet.last_response() and fix a few bugs with the datetime
  testing harness.  Remove the {admin,postings,request}_response attributes, but
  these are not apparently tested.
modified:
  src/mailman/database/autorespond.py
  src/mailman/database/mailinglist.py
  src/mailman/docs/autorespond.txt
  src/mailman/interfaces/autorespond.py
  src/mailman/styles/default.py
  src/mailman/utilities/datetime.py

=== modified file 'src/mailman/database/autorespond.py'
--- src/mailman/database/autorespond.py 2009-02-18 02:40:55 +0000
+++ src/mailman/database/autorespond.py 2009-02-19 05:18:35 +0000
@@ -27,7 +27,7 @@
     ]
 
 
-from storm.locals import And, Date, Int, Reference
+from storm.locals import And, Date, Desc, Int, Reference
 from zope.interface import implements
 
 from mailman.config import config
@@ -83,6 +83,16 @@
             self._mailing_list, address, response_type)
         config.db.store.add(response)
 
+    def last_response(self, address, response_type):
+        """See `IAutoResponseSet`."""
+        results = config.db.store.find(
+            AutoResponseRecord,
+            And(AutoResponseRecord.address == address,
+                AutoResponseRecord.mailing_list == self._mailing_list,
+                AutoResponseRecord.response_type == response_type)
+            ).order_by(Desc(AutoResponseRecord.date_sent)) 
+        return (None if results.count() == 0 else results.first())
+
 
 
 def adapt_mailing_list_to_response_set(iface, obj):

=== modified file 'src/mailman/database/mailinglist.py'
--- src/mailman/database/mailinglist.py 2009-02-18 03:23:12 +0000
+++ src/mailman/database/mailinglist.py 2009-02-19 05:18:35 +0000
@@ -62,9 +62,6 @@
     # will change as the schema and implementation is developed.
     next_request_id = Int()
     next_digest_number = Int()
-    admin_responses = Pickle()
-    postings_responses = Pickle()
-    request_responses = Pickle()
     digest_last_sent_at = DateTime()
     one_last_digest = Pickle()
     volume = Int()

=== modified file 'src/mailman/docs/autorespond.txt'
--- src/mailman/docs/autorespond.txt    2009-02-18 02:40:55 +0000
+++ src/mailman/docs/autorespond.txt    2009-02-19 05:18:35 +0000
@@ -70,3 +70,40 @@
     0
     >>> response_set.todays_count(address, Response.command)
     0
+
+
+Response dates
+--------------
+
+You can also use the response set to get the date of the last response sent.
+
+    >>> response = response_set.last_response(address, Response.hold)
+    >>> response.mailing_list
+    <mailing list "[email protected]" at ...>
+    >>> response.address
+    <Address: [email protected] [not verified] at ...>
+    >>> response.response_type
+    <EnumValue: Response.hold [int=1]>
+    >>> response.date_sent
+    datetime.date(2005, 8, 1)
+
+When another response is sent today, that becomes the last one sent.
+
+    >>> response_set.response_sent(address, Response.command)
+    >>> response_set.last_response(address, Response.command).date_sent
+    datetime.date(2005, 8, 2)
+
+    >>> factory.fast_forward(days=3)
+    >>> response_set.response_sent(address, Response.command)
+    >>> response_set.last_response(address, Response.command).date_sent
+    datetime.date(2005, 8, 5)
+
+If there's been no response sent to a particular address, None is returned.
+
+    >>> address = config.db.user_manager.create_address(
+    ...     u'[email protected]')
+
+    >>> response_set.todays_count(address, Response.command)
+    0
+    >>> print response_set.last_response(address, Response.command)
+    None

=== modified file 'src/mailman/interfaces/autorespond.py'
--- src/mailman/interfaces/autorespond.py       2009-02-17 04:57:30 +0000
+++ src/mailman/interfaces/autorespond.py       2009-02-19 05:18:35 +0000
@@ -37,6 +37,10 @@
     hold = 1
     # Email commands, i.e. -request messages.
     command = 2
+    # Messages to the list owner/administrator.
+    owner = 3
+    # Messages to the list's posting address.
+    postings = 4
 
 
 
@@ -85,3 +89,14 @@
         :param response_type: The response type being sent.
         :type response_type: `Response`
         """
+
+    def last_response(address, response_type):
+        """Record the fact that another response is being sent to the address.
+
+        :param address: The address who is the recipient of the auto-response.
+        :type address: `IAddress`
+        :param response_type: The response type being sent.
+        :type response_type: `Response`
+        :return: the last response recorded.
+        :rtype: `IAutoResponseRecord`
+        """

=== modified file 'src/mailman/styles/default.py'
--- src/mailman/styles/default.py       2009-02-18 03:23:12 +0000
+++ src/mailman/styles/default.py       2009-02-19 05:18:35 +0000
@@ -177,9 +177,6 @@
         mlist.autoresponse_admin_text = ''
         mlist.autoresponse_request_text = ''
         mlist.autoresponse_graceperiod = datetime.timedelta(days=90)
-        mlist.postings_responses = {}
-        mlist.admin_responses = {}
-        mlist.request_responses = {}
         # Bounces
         mlist.bounce_processing = True
         mlist.bounce_score_threshold = 5.0

=== modified file 'src/mailman/utilities/datetime.py'
--- src/mailman/utilities/datetime.py   2009-02-18 02:40:55 +0000
+++ src/mailman/utilities/datetime.py   2009-02-19 05:18:35 +0000
@@ -44,7 +44,7 @@
     predictable_today = None
 
     def now(self, tz=None):
-        return (self.predictable_now
+        return (yself.predictable_now
                 if self.testing_mode
                 else datetime.datetime.now(tz))
 
@@ -56,11 +56,12 @@
     @classmethod
     def reset(cls):
         cls.predictable_now = datetime.datetime(2005, 8, 1, 7, 49, 23)
-        cls.predictable_today = cls.predictable_now.today()
+        cls.predictable_today = cls.predictable_now.date()
 
     @classmethod
     def fast_forward(cls, days=1):
-        cls.predictable_today += datetime.timedelta(days=days)
+        cls.predictable_now += datetime.timedelta(days=days)
+        cls.predictable_today = cls.predictable_now.date()
 
 
 factory = DateFactory()



--
Primary development focus
https://code.launchpad.net/~mailman-coders/mailman/3.0

Your team Mailman Checkins is subscribed to branch lp:mailman.
To unsubscribe from this branch go to 
https://code.launchpad.net/~mailman-coders/mailman/3.0/+edit-subscription.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to