aboutsummaryrefslogtreecommitdiffstats
path: root/Mailman
diff options
context:
space:
mode:
authorbwarsaw <>2003-09-22 02:40:51 +0000
committerbwarsaw <>2003-09-22 02:40:51 +0000
commit2ab3bb7f7d16318f11775e14a421bd30049805f4 (patch)
tree142e0965b911b9142d81fee3c98b9c6b3f213bda /Mailman
parentb957dbc4b1100321697f94a78b4efd72a0f72f8c (diff)
downloadmailman2-2ab3bb7f7d16318f11775e14a421bd30049805f4.tar.gz
mailman2-2ab3bb7f7d16318f11775e14a421bd30049805f4.tar.xz
mailman2-2ab3bb7f7d16318f11775e14a421bd30049805f4.zip
Backporting from the HEAD -- updated archiver
Diffstat (limited to 'Mailman')
-rw-r--r--Mailman/Archiver/Archiver.py6
-rw-r--r--Mailman/Archiver/HyperArch.py42
-rw-r--r--Mailman/Archiver/pipermail.py4
3 files changed, 42 insertions, 10 deletions
diff --git a/Mailman/Archiver/Archiver.py b/Mailman/Archiver/Archiver.py
index 903031cd..8c41f0f8 100644
--- a/Mailman/Archiver/Archiver.py
+++ b/Mailman/Archiver/Archiver.py
@@ -1,4 +1,4 @@
-# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2003 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
@@ -166,7 +166,9 @@ class Archiver:
raise
def ExternalArchive(self, ar, txt):
- d = SafeDict({'listname': self.internal_name()})
+ d = SafeDict({'listname': self.internal_name(),
+ 'hostname': self.host_name,
+ })
cmd = ar % d
extarch = os.popen(cmd, 'w')
extarch.write(txt)
diff --git a/Mailman/Archiver/HyperArch.py b/Mailman/Archiver/HyperArch.py
index ea09b877..328e0dcc 100644
--- a/Mailman/Archiver/HyperArch.py
+++ b/Mailman/Archiver/HyperArch.py
@@ -83,6 +83,13 @@ if sys.platform == 'darwin':
resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard))
+try:
+ True, False
+except NameError:
+ True = 1
+ False = 0
+
+
def html_quote(s, lang=None):
repls = ( ('&', '&amp;'),
@@ -159,21 +166,44 @@ quotedpat = re.compile(r'^([>|:]|&gt;)+')
-# This doesn't need to be a weakref instance because it's just storing
-# strings. Keys are (templatefile, lang) tuples.
+# Like Utils.maketext() but with caching to improve performance.
+#
+# _templatefilepathcache is used to associate a (templatefile, lang, listname)
+# key with the file system path to a template file. This path is the one that
+# the Utils.findtext() function has computed is the one to match the values in
+# the key tuple.
+#
+# _templatecache associate a file system path as key with the text
+# returned after processing the contents of that file by Utils.findtext()
+#
+# We keep two caches to reduce the amount of template text kept in memory,
+# since the _templatefilepathcache is a many->one mapping and _templatecache
+# is a one->one mapping. Imagine 1000 lists all using the same default
+# English template.
+
+_templatefilepathcache = {}
_templatecache = {}
def quick_maketext(templatefile, dict=None, lang=None, mlist=None):
+ if mlist is None:
+ listname = ''
+ else:
+ listname = mlist._internal_name
if lang is None:
if mlist is None:
lang = mm_cfg.DEFAULT_SERVER_LANGUAGE
else:
lang = mlist.preferred_language
- template = _templatecache.get((templatefile, lang))
- if template is None:
+ cachekey = (templatefile, lang, listname)
+ filepath = _templatefilepathcache.get(cachekey)
+ if filepath:
+ template = _templatecache.get(filepath)
+ if filepath is None or template is None:
# Use the basic maketext, with defaults to get the raw template
- template = Utils.maketext(templatefile, lang=lang, raw=1)
- _templatecache[(templatefile, lang)] = template
+ template, filepath = Utils.findtext(templatefile, lang=lang,
+ raw=True, mlist=mlist)
+ _templatefilepathcache[cachekey] = filepath
+ _templatecache[filepath] = template
# Copied from Utils.maketext()
text = template
if dict is not None:
diff --git a/Mailman/Archiver/pipermail.py b/Mailman/Archiver/pipermail.py
index e2e6c062..210030ed 100644
--- a/Mailman/Archiver/pipermail.py
+++ b/Mailman/Archiver/pipermail.py
@@ -7,7 +7,7 @@ import os
import re
import sys
import time
-from email.Utils import parseaddr, parsedate_tz
+from email.Utils import parseaddr, parsedate_tz, mktime_tz
import cPickle as pickle
from cStringIO import StringIO
from string import lowercase
@@ -224,7 +224,7 @@ class Article:
return None
date = parsedate_tz(datestr)
try:
- return time.mktime(date[:9])
+ return mktime_tz(date)
except (TypeError, ValueError, OverflowError):
return None
date = floatdate('date')