diff options
| author | cotton | 1998-10-09 14:14:30 +0000 |
|---|---|---|
| committer | cotton | 1998-10-09 14:14:30 +0000 |
| commit | 8aa10fbdc0e464bfe1df5f244b7a2576dcc72afe (patch) | |
| tree | f4bf432ea0f5ad6a6aae9a222c5abfdcaa59149a /Mailman/Archiver.py | |
| parent | 13ca1d9ac610544b62b5b578676dc5ba9de32985 (diff) | |
| download | mailman-8aa10fbdc0e464bfe1df5f244b7a2576dcc72afe.tar.gz mailman-8aa10fbdc0e464bfe1df5f244b7a2576dcc72afe.tar.zst mailman-8aa10fbdc0e464bfe1df5f244b7a2576dcc72afe.zip | |
All these changes are for implemented integrated pipermail based archives.
Original patches are from The Dragon de Monsyne with the following changes:
-added support for private archives as well as public
-added support for archiving daily and weekly
-made archiving happen in real time
-replaced use of pipermail's BSDBDatabase with homegrown python version
-took out the need for DocumentTemplate
here's a listing of changed files and relevant changes:
Makefile.in - added public_html/archives to installdirs
Mailman/Archiver.py - changed ArchiveMail to do real time archiving
Mailman/Defaults.py.in - added archive frequency and and archive url
extension variables
Mailman/MailList.py - changed .Save() to alter perms on public vs. private
archives
Mailman/htmlformat.py - changes directly from The Dragon do Monsyne's patches.
I don't know what they are exactly, but all the cgi's
seem to work fine, so I assume they are OK.
Mailman/versions.py - changes to add archiving based variables back to the list
Mailman/Cgi/private - changed to make it work with default installation and
made background white on login page
src/Makefile.in - changes to make all wrappers setuid mailman:
since various processes may access an archive, and the
archiving mechanism uses "chmod", all archives must be owned
by mailman, so all wrappers need to be owned by and setuid mailman
added files:
Mailman/HyperArch.py - from The Dragon de Monsyne with changes made noted above
Mailman/HyperDatabase.py - the replacement for pipermail.BSDBDatabase
scott
Diffstat (limited to 'Mailman/Archiver.py')
| -rw-r--r-- | Mailman/Archiver.py | 83 |
1 files changed, 41 insertions, 42 deletions
diff --git a/Mailman/Archiver.py b/Mailman/Archiver.py index 50555f0c2..c3f1009b8 100644 --- a/Mailman/Archiver.py +++ b/Mailman/Archiver.py @@ -27,25 +27,17 @@ import sys, os, string import Utils import Mailbox import mm_cfg +import sys -## ARCHIVE_PENDING = "to-archive.mail" -## # ARCHIVE_RETAIN will be ignored, below, in our hook up with andrew's new -## # pipermail. -## ARCHIVE_RETAIN = "retained.mail" - class Archiver: def InitVars(self): # Configurable self.archive = 1 # 0=public, 1=private: self.archive_private = mm_cfg.DEFAULT_ARCHIVE_PRIVATE -## self.archive_update_frequency = \ -## mm_cfg.DEFAULT_ARCHIVE_UPDATE_FREQUENCY -## self.archive_volume_frequency = \ -## mm_cfg.DEFAULT_ARCHIVE_VOLUME_FREQUENCY -## self.archive_retain_text_copy = \ -## mm_cfg.DEFAULT_ARCHIVE_RETAIN_TEXT_COPY + self.archive_volume_frequency = \ + mm_cfg.DEFAULT_ARCHIVE_VOLUME_FREQUENCY # Not configurable self.clobber_date = 0 @@ -62,10 +54,10 @@ class Archiver: def GetBaseArchiveURL(self): if self.archive_private: return os.path.join(mm_cfg.PRIVATE_ARCHIVE_URL, - self._internal_name + ".html") + self._internal_name + mm_cfg.PRIVATE_ARCHIVE_URL_EXT) else: return os.path.join(mm_cfg.PUBLIC_ARCHIVE_URL, - self._internal_name + ".html") + self._internal_name + mm_cfg.PRIVATE_ARCHIVE_URL_EXT) def GetConfigInfo(self): return [ @@ -81,17 +73,10 @@ class Archiver: 'Set date in archive to when the mail is claimed to have been ' 'sent, or to the time we resend it?'), -## ('archive_update_frequency', mm_cfg.Number, 3, 0, -## "How often should new messages be incorporated? " -## "0 for no archival, 1 for daily, 2 for hourly"), - -## ('archive_volume_frequency', mm_cfg.Radio, ('Yearly', 'Monthly'), -## 0, -## 'How often should a new archive volume be started?'), + ('archive_volume_frequency', mm_cfg.Radio, + ('Yearly', 'Monthly','Quarterly', 'Weekly', 'Daily'), 0, + 'How often should a new archive volume be started?'), -## ('archive_retain_text_copy', mm_cfg.Toggle, ('No', 'Yes'), -## 0, -## 'Retain plain text copy of archive?'), ] def UpdateArchive(self): @@ -123,26 +108,35 @@ class Archiver: f.truncate(0) f.close() -# Internal function, don't call this. - def ArchiveMail(self, post): - """Retain a text copy of the message in an mbox file.""" - if self.clobber_date: - import time - olddate = post.getheader('date') - post.SetHeader('Date', time.ctime(time.time())) + + # + # archiving in real time this is called from list.post(msg) + # + def ArchiveMail(self, msg): + # + # first we fork so that errors here won't + # disrupt normal list delivery -scott + # + if os.fork(): + return try: - afn = self.ArchiveFileName() - mbox = self.ArchiveFile(afn) - mbox.AppendMessage(post) - mbox.fp.close() - except IOError, msg: - self.LogMsg("error", ("Archive file access failure:\n" - "\t%s %s" - % (afn, `msg[1]`))) - if self.clobber_date: - # Resurrect original date setting. - post.SetHeader('Date', olddate) - self.Save () + from cStringIO import StringIO + except ImportError: + from StringIO import StringIO + txt = msg.unixfrom + for h in msg.headers: + txt = txt + h + if msg.body[0] != '\n': + txt = txt + "\n" + txt = txt + msg.body + f = StringIO(txt) + import HyperArch + h = HyperArch.HyperArchive(self) + h.processUnixMailbox(f, HyperArch.Article) + h.close() + f.close() + os._exit(0) + def ArchiveFileName(self): """The mbox name where messages are left for archive construction.""" @@ -152,6 +146,7 @@ class Archiver: else: return os.path.join(self.public_archive_file_dir, self._internal_name) + def ArchiveFile(self, afn): """Open (creating, if necessary) the named archive file.""" ou = os.umask(002) @@ -162,3 +157,7 @@ class Archiver: raise IOError, msg finally: os.umask(ou) + + + + |
