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

Mark Sapiro msapiro at value.net
Wed Jan 26 01:37:18 CET 2005


Christopher Adams wrote:
>
>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!
<snip>


There are two things wrong with what you have above. Assuming it's not
a typo, there is a missing single-quote - i.e.

             'listinfo_url : listinfo_url,

should be

             'listinfo_url' : listinfo_url,

But there is a more serious problem in that while 'listinfo_url' is
basically an arbitrary key, the entity to the right of the : must
evaluate to something. In this case, listinfo_url would be a variable
that has no definition within MailList.py. What you need is something
like

             'listinfo_url' : self.getScriptUrl('listinfo', absolute=1),

or you could define the variable listinfo_url first as in

            listinfo_url = self.getScriptUrl('listinfo', absolute=1)
            text = Utils.maketext(
                '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)

Note that the exact way to actually get the URL depends on the fact
that we are doing this within the definitions of the MailList class.
Elswhere we might need something like mlist.getScriptUrl() instead of
self.getScriptUrl().

Also note that there are two invocations of
Utils.maketext('verify.txt', ...) in MailList.py and the one that has
'email'      : newaddr, and 'remote'     : '', is the one for
verifying an address change. The one for verifying a new subscription
is closer to the beginning.


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