[Mailman-Users] use of Python strings in template files
Mark Sapiro
msapiro at value.net
Tue Jan 25 23:10:05 CET 2005
Christopher Adams wrote:
>I have posted this question to the list before, but have never resolved it.
>
>I am looking at the files in the template directory, specifically
>newlist.txt and verify.txt. The newlist file is the information sent to
>list owners when the list is set up. The verify file is the information
>sent to confirm an email address when a person subscribes to a list that
>requires confirmation.
>
>I want to make some changes to this information, which affects all
>lists. I can make some changes, but some don't seem to work. The most
>significant is the Python strings that parse information into links,
>specifically %(listinfo_url)s and %(emailaddr)s . If I insert
>%(emailaddr)s into the newlist.txt file, when I generate a new list,
>the exact text %(emailaddr)s shows in the message and it doesn't render
>it as newlist at wherever.com. If I insert into the verify.txt file, I get
>the same result. My confusion comes in when I see that these strings are
>used successfully in other template files.
>
>What gives? Is there something contextual about the use of these strings
>that makes them unuseable in other templates?
Yes there is. The interpolation is done in Utils.py by findtext() which
in most cases is called via maketext(). The caller to these routines
specifies a template and a dictionary to be used for interpolations
into that template. Thus each template has its own dictionary.
For example, if you 'cd' to your mailman installation and do
grep -r verify\.txt *
you'll find the only code references to verify.txt are in MailList.py.
These in turn are in adding a new member where confirmation is required
text = Utils.maketext(
'verify.txt',
{'email' : email,
'listaddr' : self.GetListEmail(),
'listname' : realname,
'cookie' : cookie,
'requestaddr' : self.GetRequestEmail(),
'remote' : remote,
'listadmin' : self.GetOwnerEmail(),
'confirmurl' : confirmurl,
}, lang=lang, mlist=self)
and in changing a member address
text = Utils.maketext(
'verify.txt',
{'email' : newaddr,
'listaddr' : self.GetListEmail(),
'listname' : realname,
'cookie' : cookie,
'requestaddr': self.GetRequestEmail(),
'remote' : '',
'listadmin' : self.GetOwnerEmail(),
'confirmurl' : confirmurl,
}, lang=lang, mlist=self)
Thus, unless you add items to the dictionary in these calls, the only
items that will be interpolated in the verify.txt template are
'email', 'listaddr', 'listname', 'cookie', 'requestaddr', 'remote',
'listadmin' and 'confirmurl'.
--
Mark Sapiro <msapiro at value.net> The highway is for gamblers,
San Francisco Bay Area, California better use your sense - B. Dylan
More information about the Mailman-Users
mailing list