Mark Sapiro wrote:
>
>However, since it's a slow Saturday, see the attached DuplicatePost.py
>handler.
I should know better. The attachment was stripped from the list by
content filtering. Ti is attached again as DuplicatePost.py.txt, but
of course needs to be renamed for use.
--
Mark Sapiro <[EMAIL PROTECTED]> The highway is for gamblers,
San Francisco Bay Area, California better use your sense - B. Dylan
# Copyright (C) 2008 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""Drop or hold posts with the same Message-ID as another recent post
to this list.
"""
import time
from Mailman import Errors
from Mailman import mm_cfg
from Mailman.Handlers.Hold import hold_for_approval
class DuplicatePost(Errors.HoldMessage):
reason = 'Post with duplicate Message-ID'
rejection = """This post has the same Message-ID as another recent post
to this list."""
def process(mlist, msg, msgdata):
now = time.time()
old = now - mm_cfg.MESSAGE_ID_EXPIRES_AFTER
id = msg['message-id']
if not id:
return
saved_time = 0
try:
saved_time = mlist.recent_message_ids[id]
except AttributeError:
mlist.recent_message_ids = {}
except KeyError:
pass
mlist.recent_message_ids[id] = now
for k, v in mlist.recent_message_ids.items():
if v <= old:
del mlist.recent_message_ids[k]
if saved_time > old:
if mm_cfg.HOLD_DUPLICATE_MESSAGES:
hold_for_approval(mlist, msg, msgdata, DuplicatePost)
else:
raise Errors.DiscardMessage
------------------------------------------------------
Mailman-Users mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe:
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org
Security Policy: http://wiki.list.org/x/QIA9