diff options
Diffstat (limited to 'Mailman/Utils.py')
-rw-r--r-- | Mailman/Utils.py | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/Mailman/Utils.py b/Mailman/Utils.py index ceb63f66..13e751a7 100644 --- a/Mailman/Utils.py +++ b/Mailman/Utils.py @@ -360,6 +360,17 @@ def websafe(s): return cgi.escape(s, quote=1) +def nntpsplit(s): + parts = s.split(':', 1) + if len(parts) == 2: + try: + return parts[0], int(parts[1]) + except ValueError: + pass + # Use the defaults + return s, 119 + + # Just changing these two functions should be enough to control the way # that email address obscuring is handled. @@ -381,7 +392,7 @@ def UnobscureEmail(addr): -def maketext(templatefile, dict=None, raw=False, lang=None, mlist=None): +def findtext(templatefile, dict=None, raw=False, lang=None, mlist=None): # Make some text from a template file. The order of searches depends on # whether mlist and lang are provided. Once the templatefile is found, # string substitution is performed by interpolation in `dict'. If `raw' @@ -426,6 +437,12 @@ def maketext(templatefile, dict=None, raw=False, lang=None, mlist=None): # on the above description. Mailman's upgrade script cannot do this for # you. # + # The function has been revised and renamed as it now returns both the + # template text and the path from which it retrieved the template. The + # original function is now a wrapper which just returns the template text + # as before, by calling this renamed function and discarding the second + # item returned. + # # Calculate the languages to scan languages = [] if lang is not None: @@ -460,7 +477,8 @@ def maketext(templatefile, dict=None, raw=False, lang=None, mlist=None): # Try one last time with the distro English template, which, unless # you've got a really broken installation, must be there. try: - fp = open(os.path.join(mm_cfg.TEMPLATE_DIR, 'en', templatefile)) + filename = os.path.join(mm_cfg.TEMPLATE_DIR, 'en', templatefile) + fp = open(filename) except IOError, e: if e.errno <> errno.ENOENT: raise # We never found the template. BAD! @@ -483,8 +501,12 @@ def maketext(templatefile, dict=None, raw=False, lang=None, mlist=None): syslog('error', 'broken template: %s\n%s', filename, e) pass if raw: - return text - return wrap(text) + return text, filename + return wrap(text), filename + + +def maketext(templatefile, dict=None, raw=False, lang=None, mlist=None): + return findtext(templatefile, dict, raw, lang, mlist)[0] |