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

Mark Sapiro mark at msapiro.net
Thu Aug 21 03:03:41 CEST 2008


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



More information about the Mailman-Users mailing list