summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw1999-08-21 05:13:23 +0000
committerbwarsaw1999-08-21 05:13:23 +0000
commitd32edf3685107a87a3645ca4f4df4bda165e249b (patch)
tree681fdb5b5beb2ddbea8b5b6a19b850ccd593691c
parentf770c8f34026d4734b03c3e7a59ce75950da9f97 (diff)
downloadmailman-d32edf3685107a87a3645ca4f4df4bda165e249b.tar.gz
mailman-d32edf3685107a87a3645ca4f4df4bda165e249b.tar.zst
mailman-d32edf3685107a87a3645ca4f4df4bda165e249b.zip
Extensive changes based on Jeremy Hylton's investigations. These
should considerably help the performance of the archiver. Specifically: update_dirty_archives(): Archived articles are appended to the .txt file, and a gzip'd copy used to be written automatically. However this turns out to be a huge performance hit (it's not very efficient to do the entire gzip in Python, and we can't use gzip's append feature because apparently Netscape doesn't know how to grok gzip append files). The gzip file only now gets created if 1) gzip can be imported, and 2) mm_cfg.GZIP_ARCHIVE_TXT_FILES is true. XXX: note that we should add a cronjob to gzip the file nightly. consolidate imports
-rw-r--r--Mailman/Archiver/HyperArch.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/Mailman/Archiver/HyperArch.py b/Mailman/Archiver/HyperArch.py
index 92fce247f..fc630cef8 100644
--- a/Mailman/Archiver/HyperArch.py
+++ b/Mailman/Archiver/HyperArch.py
@@ -42,12 +42,14 @@ from Mailman.Utils import mkdir, open_ex
# TBD: ugly, ugly, ugly -baw
open = open_ex
-try:
- import gzip
-except ImportError:
- gzip = None
-
+gzip = None
+if mm_cfg.GZIP_ARCHIVE_TXT_FILES:
+ try:
+ import gzip
+ except ImportError:
+ pass
+
def html_quote(s):
repls = ( ('&', '&'),
("<", '&lt;'),
@@ -204,7 +206,6 @@ class Article(pipermail.Article):
def __init__(self, message=None, sequence=0, keepHeaders=[]):
- import time
if message==None: return
self.sequence=sequence
@@ -533,7 +534,7 @@ class HyperArchive(pipermail.T):
# can't init the database while other
# processes are writing to it!
# XXX TODO- implement native locking
- # with mailman's flock module for HyperDatabase.HyperDatabase
+ # with mailman's LockFile module for HyperDatabase.HyperDatabase
#
pipermail.T.__init__(
self,
@@ -721,7 +722,6 @@ class HyperArchive(pipermail.T):
f.flush()
def open_new_archive(self, archive, archivedir):
- import os
index_html=os.path.join(archivedir, 'index.html')
try: os.unlink(index_html)
except: pass
@@ -739,7 +739,6 @@ class HyperArchive(pipermail.T):
def write_index_footer(self):
- import string
for i in range(self.depth): print '</UL>'
print self.html_foot()
@@ -869,15 +868,17 @@ class HyperArchive(pipermail.T):
def update_dirty_archives(self):
for i in self._dirty_archives:
self.update_archive(i)
- archz=None
- archt=None
- # only do this if the gzip module was imported globally
+ # only do this if the gzip module was imported globally, and
+ # gzip'ing was enabled via mm_cfg.GZIP_ARCHIVE_TXT_FILES. See
+ # above.
if gzip:
+ archz=None
+ archt=None
try:
txtfile = os.path.join(self.basedir, '%s.txt' % i)
gzipfile = os.path.join(self.basedir, '%s.txt.gz' % i)
oldgzip = os.path.join(self.basedir, '%s.old.txt.gz' % i)
-
+ # open the plain text file
archt = open(txtfile, 'r')
try:
os.rename(gzipfile, oldgzip)
@@ -975,7 +976,6 @@ class HyperArchive(pipermail.T):
# Escape all special characters
def __processbody_CGIescape(self, source, dest):
- import cgi
for i in xrange(0, len(source)):
if source[i]!=None:
dest[i]=cgi.escape(source[i]) ; source[i]=None
@@ -1030,7 +1030,6 @@ class HyperArchive(pipermail.T):
return article
def update_article(self, arcdir, article, prev, next):
- import os
self.message('Updating HTML for article '+str(article.sequence))
try:
f=open(os.path.join(arcdir, article.filename), 'r')