Skip to content

Commit 8d89e1c

Browse files
author
Richard Jones
committed
mailgw can override the MAIL_DEFUALT_CLASS
1 parent d551bf4 commit 8d89e1c

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

roundup/mailgw.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class node. Any parts of other types are each stored in separate files
7474
an exception, the original message is bounced back to the sender with the
7575
explanatory message given in the exception.
7676
77-
$Id: mailgw.py,v 1.154 2004-09-07 10:40:15 richard Exp $
77+
$Id: mailgw.py,v 1.155 2004-09-14 22:09:48 richard Exp $
7878
"""
7979
__docformat__ = 'restructuredtext'
8080

@@ -311,10 +311,15 @@ class MailGW:
311311
(\[(?P<args>.+?)\])? # [prop=value]
312312
''', re.IGNORECASE|re.VERBOSE)
313313

314-
def __init__(self, instance, db, arguments={}):
314+
def __init__(self, instance, db, arguments=()):
315315
self.instance = instance
316316
self.db = db
317317
self.arguments = arguments
318+
self.default_class = None
319+
for option, value in self.arguments:
320+
if option == '-c':
321+
self.default_class = value.strip()
322+
318323
self.mailer = Mailer(instance.config)
319324
self.logger = instance.config.logging.getLogger('mailgw')
320325

@@ -634,6 +639,8 @@ def handle_message(self, message):
634639
sendto = [from_list[0][1]]
635640
self.mailer.standard_message(sendto, subject, '')
636641
return
642+
elif self.default_class:
643+
classname = self.default_class
637644
else:
638645
classname = config['MAILGW_DEFAULT_CLASS']
639646
if not classname:

roundup/scripts/roundup_mailgw.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1515
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1616
#
17-
# $Id: roundup_mailgw.py,v 1.19 2004-07-27 00:57:18 richard Exp $
17+
# $Id: roundup_mailgw.py,v 1.20 2004-09-14 22:09:48 richard Exp $
1818

1919
"""Command-line script stub that calls the roundup.mailgw.
2020
"""
@@ -33,10 +33,11 @@ def usage(args, message=None):
3333
if message is not None:
3434
print message
3535
print _(
36-
"""Usage: %(program)s [-v] [[-C class] -S field=value]* <instance home> [method]
36+
"""Usage: %(program)s [-v] [-c] [[-C class] -S field=value]* <instance home> [method]
3737
3838
Options:
3939
-v: print version and exit
40+
-c: default class of item to create (else the tracker's MAIL_DEFAULT_CLASS)
4041
-C / -S: see below
4142
4243
The roundup mail gateway may be called in one of four ways:
@@ -103,7 +104,7 @@ def main(argv):
103104
# take the argv array and parse it leaving the non-option
104105
# arguments in the args array.
105106
try:
106-
optionsList, args = getopt.getopt(argv[1:], 'vC:S:', ['set=',
107+
optionsList, args = getopt.getopt(argv[1:], 'vcC:S:', ['set=',
107108
'class='])
108109
except getopt.GetoptError:
109110
# print help information and exit:

0 commit comments

Comments
 (0)