summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Mailman/Handlers/Hold.py20
-rw-r--r--Mailman/LockFile.py14
-rw-r--r--Mailman/Message.py2
-rw-r--r--Mailman/Queue/NewsRunner.py2
-rw-r--r--Mailman/docs/addresses.txt8
-rw-r--r--Mailman/docs/hold.txt10
-rw-r--r--Mailman/docs/news-runner.txt6
-rw-r--r--Mailman/docs/pending.txt2
8 files changed, 39 insertions, 25 deletions
diff --git a/Mailman/Handlers/Hold.py b/Mailman/Handlers/Hold.py
index d4f4845e5..0db0a5c94 100644
--- a/Mailman/Handlers/Hold.py
+++ b/Mailman/Handlers/Hold.py
@@ -35,12 +35,14 @@ import email.utils
from email.mime.message import MIMEMessage
from email.mime.text import MIMEText
from types import ClassType
+from zope.interface import implements
from Mailman import Errors
from Mailman import Message
-from Mailman import Pending
from Mailman import Utils
from Mailman import i18n
+from Mailman.configuration import config
+from Mailman.interfaces import IPendable, IPending
log = logging.getLogger('mailman.vette')
@@ -129,6 +131,12 @@ def ackp(msg):
+class HeldMessagePendable(dict):
+ implements(IPendable)
+ PEND_KEY = 'held message'
+
+
+
def process(mlist, msg, msgdata):
if msgdata.get('approved'):
return
@@ -239,7 +247,9 @@ def hold_for_approval(mlist, msg, msgdata, exc):
#
# This message should appear to come from <list>-admin so as to handle any
# bounce processing that might be needed.
- cookie = mlist.pend_new(Pending.HELD_MESSAGE, id)
+ pendable = HeldMessagePendable(type=HeldMessagePendable.PEND_KEY,
+ id=str(id))
+ token = IPending(config.db).add(pendable)
# Get the language to send the response in. If the sender is a member,
# then send it in the member's language, otherwise send it in the mailing
# list's preferred language.
@@ -247,9 +257,9 @@ def hold_for_approval(mlist, msg, msgdata, exc):
lang = (member.preferred_language if member else mlist.preferred_language)
if not fromusenet and ackp(msg) and mlist.respond_to_post_requests and \
mlist.autorespondToSender(sender, lang):
- # Get a confirmation cookie
+ # Get a confirmation token
d['confirmurl'] = '%s/%s' % (mlist.GetScriptURL('confirm', absolute=1),
- cookie)
+ token)
lang = msgdata.get('lang', lang)
subject = _('Your message to $listname awaits moderator approval')
text = Utils.maketext('postheld.txt', d, lang=lang, mlist=mlist)
@@ -284,7 +294,7 @@ this message and include an Approved: header with the list password in it, the
message will be approved for posting to the list. The Approved: header can
also appear in the first line of the body of the reply.""")),
_charset=Utils.GetCharSet(lang))
- dmsg['Subject'] = 'confirm ' + cookie
+ dmsg['Subject'] = 'confirm ' + token
dmsg['Sender'] = requestaddr
dmsg['From'] = requestaddr
dmsg['Date'] = email.utils.formatdate(localtime=True)
diff --git a/Mailman/LockFile.py b/Mailman/LockFile.py
index d83cef7e2..33008e92b 100644
--- a/Mailman/LockFile.py
+++ b/Mailman/LockFile.py
@@ -59,12 +59,13 @@ import errno
import random
import socket
import logging
+import datetime
import traceback
# Units are floating-point seconds.
-DEFAULT_LOCK_LIFETIME = 15
+DEFAULT_LOCK_LIFETIME = datetime.timedelta(seconds=15)
# Allowable a bit of clock skew
-CLOCK_SLOP = 10
+CLOCK_SLOP = datetime.timedelta(seconds=10)
# This is appropriate for Mailman, but you may want to change this if you're
# using this code outside Mailman.
log = logging.getLogger('mailman.locks')
@@ -95,8 +96,8 @@ class LockFile:
Create the resource lock using lockfile as the global lock file. Each
process laying claim to this resource lock will create their own
temporary lock files based on the path specified by lockfile.
- Optional lifetime is the number of seconds the process expects to hold
- the lock.
+ Optional lifetime is a timedelta specifying the number of seconds the
+ process expects to hold the lock.
set_lifetime(lifetime):
Set a new lock lifetime. This takes affect the next time the file is
@@ -155,7 +156,7 @@ class LockFile:
self._owned = True
def __repr__(self):
- return '<LockFile %s: %s [%s: %ssec] pid=%s>' % (
+ return '<LockFile %s: %s [%s: %s] pid=%s>' % (
id(self), self._lockfile,
self.locked() and 'locked' or 'unlocked',
self._lifetime, os.getpid())
@@ -400,7 +401,8 @@ class LockFile:
return None
def _touch(self, filename=None):
- t = time.time() + self._lifetime
+ expiration_date = datetime.datetime.now() + self._lifetime
+ t = time.mktime(expiration_date.timetuple())
try:
# XXX We probably don't need to modify atime, but this is easier.
os.utime(filename or self._tmpfname, (t, t))
diff --git a/Mailman/Message.py b/Mailman/Message.py
index 0ae724009..5214d3caa 100644
--- a/Mailman/Message.py
+++ b/Mailman/Message.py
@@ -253,7 +253,7 @@ class UserNotification(Message):
reduced_list_headers=True,
)
if mlist is not None:
- enqueue_kws[listname] = mlist.fqdn_listname
+ enqueue_kws['listname'] = mlist.fqdn_listname
enqueue_kws.update(_kws)
virginq.enqueue(self, **enqueue_kws)
diff --git a/Mailman/Queue/NewsRunner.py b/Mailman/Queue/NewsRunner.py
index 48e3f48ee..709ec4e17 100644
--- a/Mailman/Queue/NewsRunner.py
+++ b/Mailman/Queue/NewsRunner.py
@@ -138,7 +138,7 @@ def prepare_message(mlist, msg, msgdata):
hackmsgid = False
if hackmsgid:
del msg['message-id']
- msg['Message-ID'] = Utils.unique_message_id(mlist)
+ msg['Message-ID'] = email.utils.make_msgid()
# Lines: is useful
if msg['Lines'] is None:
# BAW: is there a better way?
diff --git a/Mailman/docs/addresses.txt b/Mailman/docs/addresses.txt
index d1e83522e..aa3f3a5a3 100644
--- a/Mailman/docs/addresses.txt
+++ b/Mailman/docs/addresses.txt
@@ -124,7 +124,7 @@ the address was validated on. Neither date is set by default.
>>> flush()
>>> print address_4.registered_on
None
- >>> print address_4.validated_on
+ >>> print address_4.verified_on
None
The registered date takes a Python datetime object.
@@ -134,16 +134,16 @@ The registered date takes a Python datetime object.
>>> flush()
>>> print address_4.registered_on
2007-05-08 22:54:01
- >>> print address_4.validated_on
+ >>> print address_4.verified_on
None
And of course, you can also set the validation date.
- >>> address_4.validated_on = datetime(2007, 5, 13, 22, 54, 1)
+ >>> address_4.verified_on = datetime(2007, 5, 13, 22, 54, 1)
>>> flush()
>>> print address_4.registered_on
2007-05-08 22:54:01
- >>> print address_4.validated_on
+ >>> print address_4.verified_on
2007-05-13 22:54:01
diff --git a/Mailman/docs/hold.txt b/Mailman/docs/hold.txt
index 7a06c4b81..9574a7935 100644
--- a/Mailman/docs/hold.txt
+++ b/Mailman/docs/hold.txt
@@ -229,6 +229,7 @@ can show this by first holding a message.
Traceback (most recent call last):
...
ImplicitDestination
+ >>> flush()
There should be two messages in the virgin queue, one to the list owner and
one to the original author.
@@ -352,10 +353,11 @@ first item is a type code and the second item is a message id.
... if mo:
... cookie = mo.group('cookie')
... break
- >>> data = mlist.pend_confirm(cookie)
- >>> data
- ('H', ...)
- >>> filename = 'heldmsg-_xtest@example.com-%d.pck' % data[1]
+ >>> from Mailman.interfaces import IPending
+ >>> data = IPending(config.db).confirm(cookie)
+ >>> sorted(data.items())
+ [('id', '...'), ('type', 'held message')]
+ >>> filename = 'heldmsg-_xtest@example.com-%s.pck' % data['id']
>>> heldmsg = os.path.join(config.DATA_DIR, filename)
Use helper function to read the held message.
diff --git a/Mailman/docs/news-runner.txt b/Mailman/docs/news-runner.txt
index f5189c0e0..2635710a8 100644
--- a/Mailman/docs/news-runner.txt
+++ b/Mailman/docs/news-runner.txt
@@ -44,7 +44,7 @@ prohibited headers.
From: aperson@example.com
To: _xtest@example.com
Newsgroups: comp.lang.python
- Message-ID: <mailman..._xtest@example.com>
+ Message-ID: ...
Lines: 1
<BLANKLINE>
A message
@@ -74,7 +74,7 @@ X-Original-* header that the news server doesn't care about.
>>> print msg.as_string()
From: aperson@example.com
Newsgroups: comp.lang.python
- Message-ID: <mailman..._xtest@example.com>
+ Message-ID: ...
Lines: 1
To: _xtest@example.com
X-Original-To: two@example.com
@@ -109,7 +109,7 @@ the message.
Cc: someother@example.com
Content-Transfer-Encoding: yes
Newsgroups: comp.lang.python
- Message-ID: <mailman..._xtest@example.com>
+ Message-ID: ...
Lines: 1
<BLANKLINE>
A message
diff --git a/Mailman/docs/pending.txt b/Mailman/docs/pending.txt
index 518dadf87..4bdd7dec3 100644
--- a/Mailman/docs/pending.txt
+++ b/Mailman/docs/pending.txt
@@ -15,7 +15,7 @@ This is not where messages held for administrator approval are kept.
In order to pend an event, you first need a pending database, which is
available by adapting the list manager.
- >>> pendingdb = IPending(config.list_manager)
+ >>> pendingdb = IPending(config.db)
>>> verifyObject(IPending, pendingdb)
True