[Mailman-Developers] [root@tolna.net: Cron <list@melanie> /usr/bin/python /var/lib/mailman/cron/mailpasswds]
Sean Reifschneider
jafo@tummy.com
Wed, 1 Sep 1999 10:22:15 -0600
On Wed, Sep 01, 1999 at 12:04:20PM +0200, Peter Gervai wrote:
> File "/var/lib/mailman/Mailman/Utils.py", line 610, in maketext
> return wrap(template % dict)
>KeyError: one_list
It looks like your cronpass.txt template has a "%(one_list)s" in it, which
doesn't exist in the data being passed. The only values allowed for
substitution in there are hostname, useraddr, exreq, and owner.
Did you perhaps modify the cronpass.txt template?
Here's a patch that will fix it in any case. It causes any invalid
"%(key)" format strings to remain as they are instead of throwing
KeyErrors.
Sean
=====================
*** Utils.py.old Wed Sep 1 10:10:40 1999
--- Utils.py Wed Sep 1 10:16:47 1999
***************
*** 33,38 ****
--- 33,54 ----
import random
import mm_cfg
import Errors
+ import UserDict
+
+
+ class SaferDict(UserDict.UserDict):
+ '''Dictionary which returns a default value for unknown keys.'''
+
+ def __init__(self, dict, default = '<Unknown field "%s">'):
+ UserDict.UserDict.__init__(self, dict)
+ self.default = default
+
+ def __getitem__(self, key):
+ try: return(self.data[key])
+ except KeyError: pass
+ try: return(self.default % ( key ))
+ except TypeError: return(self.default)
+
def list_names():
"""Return the names of all lists in default list directory."""
***************
*** 606,613 ****
template = fp.read()
fp.close()
if raw:
! return template % dict
! return wrap(template % dict)
#
--- 622,629 ----
template = fp.read()
fp.close()
if raw:
! return template % SaferDict(dict, '%%(%s)s')
! return wrap(template % SaferDict(dict), '%%(%s)s')
#
--
It is not enough to have a good mind. The main thing is to use it well.
-- Rene Descartes
Sean Reifschneider, Inimitably Superfluous <jafo@tummy.com>
URL: <http://www.tummy.com/xvscan> HP-UX/Linux/FreeBSD/BSDOS scanning software.