[Mailman-Users] use of Python strings in template files

Christopher Adams chris.a.adams at state.or.us
Wed Jan 26 00:50:41 CET 2005


Mark,

Thank you for your timely reply. I sort of understand what you are 
saying. I edited MailList.py to look like this:

'verify.txt',
            {'email'      : newaddr,
             'listaddr'   : self.GetListEmail(),
             'listname'   : realname,
             'cookie'     : cookie,
             'requestaddr': self.GetRequestEmail(),
             'remote'     : '',
             'listadmin'  : self.GetOwnerEmail(),
             'listinfo_url : listinfo_url,
             'confirmurl' : confirmurl,
             }, lang=lang, mlist=self)


I then restarted Mailman.

When I tried to subscribe to a list that required confirmation, I got this:

Bug in Mailman version 2.1.5
We're sorry, we hit a bug!
If you would like to help us identify the problem, please email a copy of
this page to the webmaster for this site with a description of what
happened. Thanks! 
Traceback:
Traceback (most recent call last):
  File "/lists/scripts/driver", line 87, in run_main
    main()
  File "/lists/Mailman/Cgi/subscribe.py", line 96, in main
    process_form(mlist, doc, cgidata, language)
  File "/lists/Mailman/Cgi/subscribe.py", line 176, in process_form
    mlist.AddMember(userdesc, remote)
  File "/lists/Mailman/MailList.py", line 868, in AddMember
    {'email'       : email,
NameError: global name 'listinfo_url' is not defined


So, I removed the listinfo_url entry and it is back to normal.

Any idea what happened?



Mark Sapiro wrote:

>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
>
>  
>

-- 
Christopher Adams
Library Systems Analyst
Oregon State Library
503-378-4243 258
chris.a.adams at state.or.us




More information about the Mailman-Users mailing list