From fec68744a725bf02c96ccd204c0a6837a3cb5ec6 Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Mon, 5 Nov 2001 23:28:41 +0000 Subject: ChangeHTML(): Must make sure the language-specific directory for the list exists before we try to write the template file. --- Mailman/Cgi/edithtml.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Mailman/Cgi/edithtml.py b/Mailman/Cgi/edithtml.py index eee07540f..ae0b13d46 100644 --- a/Mailman/Cgi/edithtml.py +++ b/Mailman/Cgi/edithtml.py @@ -18,6 +18,7 @@ import os import cgi +import errno from Mailman import Utils from Mailman import MailList @@ -151,9 +152,16 @@ def ChangeHTML(mlist, cgi_info, template_name, doc): doc.AddItem('
') return code = cgi_info['html_code'].value - fp = open(os.path.join(mlist.fullpath(), mlist.preferred_language, - template_name), 'w') - fp.write(code) - fp.close() + langdir = os.path.join(mlist.fullpath(), mlist.preferred_language) + # Make sure the directory exists + try: + os.mkdir(langdir, 02775) + except OSError, e: + if e.errno <> errno.EEXIST: raise + fp = open(os.path.join(langdir, template_name), 'w') + try: + fp.write(code) + finally: + fp.close() doc.AddItem(Header(3, _('HTML successfully updated.'))) doc.AddItem('
') -- cgit v1.3.1