[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] mail address handling in mailer.py

From: Mathias Weinert <mathias.weinert_at_gfa-net.de>
Date: 2006-05-30 08:49:22 CEST

Hi there,

I am still hoping that some will commit the following patch to mailer.py
so please let my wishes get true...

This patch adds a new parameter to the configuration file which allows
to use different characters for splitting the to_addr.

This is usefull for using additional name information in the mail
addresses. Example:

 to_addr_split_char = ,
 to_addr = "The great Wallace" <wallace@atanyaddress>, "little Grommit" <grommit@propablyatthesameaddress>

This was the simple example (which doesn't make so much sense).
A more reasonable example is the following one:

 [defaults]
 from_addr = %(author)s
 
 [maps]
 from_addr = [mail_addresses]
 to_addr = [mail_addresses]
 
 [mail_addresses]
 wallace = "SVN: Wallace" <wallace@atanyaddress>
 grommit = "SVN: Grommit" <grommit@propablyatthesameaddress>
 
 [config_for_wallace]
 to_addr = wallace
 ...
 
With this I at least don't use the comma as separator but don't
use the whitespaces any more and am therefor able to use one set
of mail addresses containing blanks which I use for the to_addr
as well as for the from_addr. So I have the mail address only
once in the config file and the mails that are sent can easily
be identified in the mail client by the address which starts with
'SVN: '.
For me this is a really usefull thing.

If there are objections about the new parameter 'to_addr_split_char'
here are some alternatives:

1. Change the default behavior from whitespace to comma
   -> May result in problems for people updating to this version
2. Introduce a new parameter to specify the separator
   -> As I did in my patch
3. Introduce a new parameter for to_addr which will be splitted
   by comma and deprecate the current one
   -> That's what Greg Stein proposed
4. Introduce a new parameter for to_addr which will be splitted
   by comma and then add these mail addresses to the ones given
   by the current to_addr parameter
   -> No deprecation, no update problems, but two parameters for
      the same thing

Mathias

[[[
* tools/hook-scripts/mailer/mailer.py
  - new option 'to_addr_split_char' added which allows to use another character but the default whitespaces to separate different mail addresses

* tools/hook-scripts/mailer/mailer.conf.example
  - new option 'to_addr_split_char' added which allows to use another character but the default whitespaces to separate different mail addresses
]]]

--- mailer.py.orig 2006-05-23 02:17:16.000000000 +0200
+++ mailer.py 2006-05-30 08:39:42.154499700 +0200
@@ -183,7 +183,13 @@
     OutputBase.__init__(self, cfg, repos, prefix_param)
 
   def start(self, group, params):
- # whitespace-separated list of addresses; split into a clean list:
+ # whitespace (or as set by to_addr_split_char)-separated list
+ # of addresses; split into a clean list:
+ if self.cfg.is_set('general.to_addr_split_char'):
+ self.to_addrs = \
+ filter(None, string.split(self.cfg.get('to_addr', group, params), \
+ self.cfg.general.to_addr_split_char))
+ else:
     self.to_addrs = \
         filter(None, string.split(self.cfg.get('to_addr', group, params)))
     self.from_addr = self.cfg.get('from_addr', group, params) \
--- mailer.conf.example.orig 2005-04-15 16:37:19.000000000 +0200
+++ mailer.conf.example 2006-05-30 08:40:26.626095700 +0200
@@ -27,6 +27,12 @@
 #smtp_username = example
 #smtp_password = example
 
+# If this option is set to a character this character will be used
+# to split the mail addresses given to_addr.
+# If this option is not set all whitespace characters (but no comma)
+# are used for splitting.
+to_addr_split_char = ,
+
 # --------------------------------------------------------------------------
 
 #
@@ -166,7 +172,8 @@
 from_addr = invalid@example.com
 
 # The default To: addresses for message. One or more addresses,
-# separated by whitespace (no commas):
+# separated by whitespace (no commas) or the character set at
+# to_addr_split_char.
 to_addr = invalid@example.com
 
 # If this is set, then a Reply-To: will be inserted into the message

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue May 30 08:49:59 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.