Re: [Mailman-Users] Rejection notice substitution variables(member_moderation_notice)
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@msapiro.net] Sent: 21 August 2008 02:04 To: Rodriguez Gomez Pedro; mailman-users@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@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.
Rodriguez Gomez Pedro wrote:
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),
The line above is what I meant by 'wrapped lines'. I intended it to be
'options_url': mlist.GetOptionsURL(sender, absolute=True),
but indented as the others, but since it's inside {} and further the unintended new line is inside (), it doesn't matter because of Python's implied continuation.
} text = text % d text = Utils.to_percent(text)
I have no idea why the above would fix anything in this context. I would have to see the traceback from the TypeError to know what's going on with that, but Utils.to_percent probably doesn't have anything to do with fixing it.
There is one problem in my original. The
text = Utils.wrap(text)
should come after
text = text % d
not before so the text is wrapped after the values are interpolated.
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.
What is the traceback from that error?
-- Mark Sapiro mark@msapiro.net The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
participants (2)
-
Mark Sapiro
-
Rodriguez Gomez Pedro