diff options
| author | Barry Warsaw | 2008-10-06 22:07:04 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2008-10-06 22:07:04 -0400 |
| commit | c7340d712c640fa5992518a7cf16272f634abccc (patch) | |
| tree | 99057710fbc7b92eaa1720daea4c3a6cd5929cf3 /mailman/Utils.py | |
| parent | 6f4351721559e8b7b577d3a01216fec88121ed11 (diff) | |
| parent | f0c9fad6372a645981b5c72fe02a6ad62f35790f (diff) | |
| download | mailman-c7340d712c640fa5992518a7cf16272f634abccc.tar.gz mailman-c7340d712c640fa5992518a7cf16272f634abccc.tar.zst mailman-c7340d712c640fa5992518a7cf16272f634abccc.zip | |
Diffstat (limited to 'mailman/Utils.py')
| -rw-r--r-- | mailman/Utils.py | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/mailman/Utils.py b/mailman/Utils.py index 7975cb9d3..b9e34d5cd 100644 --- a/mailman/Utils.py +++ b/mailman/Utils.py @@ -37,13 +37,13 @@ import email.Header import email.Iterators from email.Errors import HeaderParseError -from string import ascii_letters, digits, whitespace +from string import ascii_letters, digits, whitespace, Template import mailman.templates -from mailman import Errors + from mailman import passwords -from mailman.SafeDict import SafeDict from mailman.configuration import config +from mailman.core import errors AT = '@' CR = '\r' @@ -199,15 +199,15 @@ def ValidateEmail(s): """Verify that the an email address isn't grossly evil.""" # Pretty minimal, cheesy check. We could do better... if not s or ' ' in s: - raise Errors.InvalidEmailAddress(repr(s)) + raise errors.InvalidEmailAddress(repr(s)) if _badchars.search(s) or s[0] == '-': - raise Errors.InvalidEmailAddress(repr(s)) + raise errors.InvalidEmailAddress(repr(s)) user, domain_parts = ParseEmail(s) # Local, unqualified addresses are not allowed. if not domain_parts: - raise Errors.InvalidEmailAddress(repr(s)) + raise errors.InvalidEmailAddress(repr(s)) if len(domain_parts) < 2: - raise Errors.InvalidEmailAddress(repr(s)) + raise errors.InvalidEmailAddress(repr(s)) @@ -524,8 +524,7 @@ def findtext(templatefile, dict=None, raw=False, lang=None, mlist=None): text = template if dict is not None: try: - sdict = SafeDict(dict, lang=lang) - text = sdict.interpolate(template) + text = Template(template).safe_substitute(**dict) except (TypeError, ValueError): # The template is really screwed up log.exception('broken template: %s', filename) @@ -564,30 +563,6 @@ def GetRequestURI(fallback=None, escape=True): -# Wait on a dictionary of child pids -def reap(kids, func=None, once=False): - while kids: - if func: - func() - try: - pid, status = os.waitpid(-1, os.WNOHANG) - except OSError, e: - # If the child procs had a bug we might have no children - if e.errno <> errno.ECHILD: - raise - kids.clear() - break - if pid <> 0: - try: - del kids[pid] - except KeyError: - # Huh? How can this happen? - pass - if once: - break - - - def makedirs(path, mode=02775): try: omask = os.umask(0) |
