[Mailman-Users] Rejection notice substitution variables(member_moderation_notice)

Rodriguez Gomez Pedro Pedro.Rodriguez at emea.europa.eu
Thu Aug 21 14:25:36 CEST 2008


Thanks Mark, it works like a charm!

I was puzzled with what you said about the wrapped lines, but when
testing I saw what you probably meant (one "TypeError: float argument
required" in the logs); I fixed it by adding "text =
Utils.to_percent(text)"...so that:

            elif mlist.member_moderation_action == 1:
                # Reject
                text = mlist.member_moderation_notice
                if text:
                    text = Utils.wrap(text)
                    d = {'real_name': mlist.real_name,
                         'web_page_url': mlist.web_page_url,
                         'cgiext': mm_cfg.CGIEXT,
                         '_internal_name': mlist.internal_name(),
                         'options_url': mlist.GetOptionsURL(sender,
absolute=True),
                         }
                    text = text % d
                    text = Utils.to_percent(text)
                else:
                    # Use the default RejectMessage notice string
                    text = None
                raise Errors.RejectMessage, text

Possibly you had a better solution in mind for that particular issue,
this one though seems to work.

Best Regards,

Pedro

-----Original Message-----
From: Mark Sapiro [mailto:mark at msapiro.net] 
Sent: 21 August 2008 02:04
To: Rodriguez Gomez Pedro; mailman-users at python.org
Subject: Re: [Mailman-Users] Rejection notice substitution
variables(member_moderation_notice)

Rodriguez Gomez Pedro wrote:
>
>I'm using Mailman 2.1.11 and in the context of defining the rejection 
>notice for moderated members (member_moderation_notice) am trying to 
>use substitution variables like:
>
>%(real_name)s
>%(web_page_url)s
>%(cgiext)s
>%(_internal_name)s
>
>or even if possible at all in that context :
>
>%(user_optionsurl)s
>
>As far as I see this is not an option now. Not being shy of modifying 
>the code, can anybody point me in the right direction?


You are correct that it is not currently an option because no variable
interpolation whatsoever is done on member_moderation_notice.

If you want to implement it, look at the process() function in
Mailman/Handlers/Moderate.py. You will see the following:

            elif mlist.member_moderation_action == 1:
                # Reject
                text = mlist.member_moderation_notice
                if text:
                    text = Utils.wrap(text)
                else:
                    # Use the default RejectMessage notice string
                    text = None
                raise Errors.RejectMessage, text

You can modify this to add interpolation by doing something like

            elif mlist.member_moderation_action == 1:
                # Reject
                text = mlist.member_moderation_notice
                if text:
                    text = Utils.wrap(text)
                    d = {'real_name': mlist.real_name,
                         'web_page_url': mlist.web_page_url,
                         'cgiext': mm_cfg.CGIEXT,
                         '_internal_name': mlist.internal_name(),
                         'options_url': mlist.GetOptionsURL(sender,
absolute=True),
                         }
                    text = text % d
                else:
                    # Use the default RejectMessage notice string
                    text = None
                raise Errors.RejectMessage, text

Note at least one (options_url) of the above lines is wrapped by my MUA
and shouldn't be wrapped.

You can look at modules like Mailman/Handlers/Decorate.py for examples
of how this is done elsewhere.

-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan


________________________________________________________________________
This e-mail has been scanned for all known viruses by EMEA.
________________________________________________________________________


More information about the Mailman-Users mailing list