Skip to content

Commit 318ae5e

Browse files
author
Richard Jones
committed
mailgw can override the MAIL_DEFUALT_CLASS
1 parent e0cf53e commit 318ae5e

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Fixed:
1010
- less specific messages for login failures (thanks Chris Withers)
1111
- Reject raised against email messages should result in email rejection, not
1212
discarding of the message
13+
- mailgw can override the MAIL_DEFUALT_CLASS
1314

1415

1516
2004-07-21 0.7.6

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.149.2.1 2004-09-07 10:37:52 richard Exp $
77+
$Id: mailgw.py,v 1.149.2.2 2004-09-14 22:03:42 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

320325
# should we trap exceptions (normal usage) or pass them through
@@ -633,6 +638,8 @@ def handle_message(self, message):
633638
sendto = [from_list[0][1]]
634639
self.mailer.standard_message(sendto, subject, '')
635640
return
641+
elif self.default_class:
642+
classname = self.default_class
636643
elif hasattr(self.instance.config, 'MAIL_DEFAULT_CLASS') and \
637644
self.instance.config.MAIL_DEFAULT_CLASS:
638645
classname = self.instance.config.MAIL_DEFAULT_CLASS

roundup/scripts/roundup_mailgw.py

Lines changed: 5 additions & 4 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.15.2.1 2004-05-28 01:03:53 richard Exp $
17+
# $Id: roundup_mailgw.py,v 1.15.2.2 2004-09-14 22:03:43 richard Exp $
1818

1919
"""Command-line script stub that calls the roundup.mailgw.
2020
"""
@@ -32,11 +32,12 @@
3232
def usage(args, message=None):
3333
if message is not None:
3434
print message
35-
print _('Usage: %(program)s [-v] [[-C class] -S field=value]* <instance '
36-
'home> [method]')%{'program': args[0]}
35+
print _('Usage: %(program)s [-v] [-c] [[-C class] -S field=value]* '
36+
'<instance home> [method]')%{'program': args[0]}
3737
print _('''
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:], 'vc:C:S:', ['set=',
107108
'class='])
108109
except getopt.GetoptError:
109110
# print help information and exit:

0 commit comments

Comments
 (0)