From: rochecompaan Date: Mon, 21 Jan 2002 10:05:48 +0000 (+0000) Subject: Feature: X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fb4ab934a3f43f5582fe58db47abcf468354c68f;p=roundup.git Feature: . the mail gateway now responds with an error message when invalid values for arguments are specified for link or multilink properties . modified unit test to check nosy and assignedto when specified as arguments Fixed: . fixed setting nosy as argument in subject line git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@572 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index 0334d9a..67d1cad 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,9 +7,14 @@ Feature: . journal entries for link and mutlilink properties can be switched on or off . properties in change note are now sorted + . the mail gateway now responds with an error message when invalid values + for arguments are specified for link or mutlilink properties. + . modified unit test to check nosy and assignedto when specified as + arguments Fixed: . handle attachments with no name (eg tnef) + . fixed setting nosy as argument in subject line 2002-01-16 - 0.4.0b2 diff --git a/roundup/mailgw.py b/roundup/mailgw.py index 8c81e6a..a47db26 100644 --- a/roundup/mailgw.py +++ b/roundup/mailgw.py @@ -73,7 +73,7 @@ are calling the create() method to create a new node). If an auditor raises an exception, the original message is bounced back to the sender with the explanatory message given in the exception. -$Id: mailgw.py,v 1.54 2002-01-16 09:14:45 grubert Exp $ +$Id: mailgw.py,v 1.55 2002-01-21 10:05:47 rochecompaan Exp $ ''' @@ -387,15 +387,32 @@ Error was: %s Subject was: "%s" '''%(key, message, subject) elif isinstance(proptype, hyperdb.Link): - link = self.db.classes[proptype.classname] - propkey = link.labelprop(default_to_id=1) - props[key] = value + linkcl = self.db.classes[proptype.classname] + propkey = linkcl.labelprop(default_to_id=1) + try: + props[key] = linkcl.lookup(value) + except KeyError, message: + raise MailUsageError, ''' +Subject argument list contains an invalid value for %s. + +Error was: %s +Subject was: "%s" +'''%(key, message, subject) elif isinstance(proptype, hyperdb.Multilink): # get the linked class linkcl = self.db.classes[proptype.classname] propkey = linkcl.labelprop(default_to_id=1) for item in value.split(','): - item = item.split() + item = item.strip() + try: + item = linkcl.lookup(item) + except KeyError, message: + raise MailUsageError, ''' +Subject argument list contains an invalid value for %s. + +Error was: %s +Subject was: "%s" +'''%(key, message, subject) if props.has_key(key): props[key].append(item) else: @@ -582,12 +599,10 @@ not find a text/plain part to use. n[nid] = 1 props['nosy'] = n.keys() # add assignedto to the nosy list - try: - assignedto = self.db.user.lookup(props['assignedto']) + if props.has_key('assignedto'): + assignedto = props['assignedto'] if assignedto not in props['nosy']: props['nosy'].append(assignedto) - except: - pass message_id = self.db.msg.create(author=author, recipients=recipients, date=date.Date('.'), summary=summary, @@ -646,10 +661,7 @@ There was a problem with the message you sent: nosy = props.get('nosy', []) n = {} for value in nosy: - if self.db.hasnode('user', value): - nid = value - else: - continue + nid = value if n.has_key(nid): continue n[nid] = 1 props['nosy'] = n.keys() @@ -667,14 +679,6 @@ There was a problem with the message you sent: # add assignedto to the nosy list if properties.has_key('assignedto') and props.has_key('assignedto'): assignedto = props['assignedto'] - if not re.match('^\d+$', assignedto): - try: - assignedto = self.db.user.lookup(assignedto) - except KeyError: - raise MailUsageError, ''' -There was a problem with the message you sent: - Assignedto user '%s' doesn't exist -'''%props['assignedto'] if not n.has_key(assignedto): props['nosy'].append(assignedto) n[assignedto] = 1 @@ -749,6 +753,9 @@ def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'), # # $Log: not supported by cvs2svn $ +# Revision 1.54 2002/01/16 09:14:45 grubert +# . if the attachment has no name, name it unnamed, happens with tnefs. +# # Revision 1.53 2002/01/16 07:20:54 richard # simple help command for mailgw # diff --git a/test/test_mailgw.py b/test/test_mailgw.py index adab1f3..0762d0e 100644 --- a/test/test_mailgw.py +++ b/test/test_mailgw.py @@ -8,7 +8,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# $Id: test_mailgw.py,v 1.5 2002-01-15 00:12:40 richard Exp $ +# $Id: test_mailgw.py,v 1.6 2002-01-21 10:05:48 rochecompaan Exp $ import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys @@ -67,7 +67,7 @@ This is a test submission of a new issue. From: Chef -Subject: [issue] Testing... [assignedto=richard] +Subject: [issue] Testing... [nosy=mary; assignedto=richard] This is a test submission of a new issue. ''') @@ -78,10 +78,10 @@ This is a test submission of a new issue. self.assertEqual(open(os.environ['SENDMAILDEBUG']).read(), '''FROM: roundup-admin@fill.me.in. -TO: chef@bork.bork.bork, richard@test +TO: chef@bork.bork.bork, mary@test, richard@test Content-Type: text/plain Subject: [issue1] Testing... -To: chef@bork.bork.bork, richard@test +To: chef@bork.bork.bork, mary@test, richard@test From: Chef Reply-To: Roundup issue tracker MIME-Version: 1.0 @@ -96,7 +96,7 @@ This is a test submission of a new issue. ---------- assignedto: richard messages: 1 -nosy: Chef, richard +nosy: mary, Chef, richard status: unread title: Testing... ___________________________________________________ @@ -113,7 +113,7 @@ From: richard To: issue_tracker@fill.me.in. Message-Id: In-Reply-To: -Subject: [issue1] Testing... +Subject: [issue1] Testing... [assignedto=mary; nosy=john] This is a followup ''') @@ -122,10 +122,10 @@ This is a followup self.assertEqual(open(os.environ['SENDMAILDEBUG']).read(), '''FROM: roundup-admin@fill.me.in. -TO: chef@bork.bork.bork +TO: chef@bork.bork.bork, mary@test, john@test Content-Type: text/plain Subject: [issue1] Testing... -To: chef@bork.bork.bork +To: chef@bork.bork.bork, mary@test, john@test From: richard Reply-To: Roundup issue tracker MIME-Version: 1.0 @@ -137,6 +137,10 @@ richard added the comment: This is a followup + +---------- +assignedto: -> mary +nosy: +mary, john ___________________________________________________ "Roundup issue tracker" http://some.useful.url/issue1 @@ -192,6 +196,9 @@ def suite(): # # $Log: not supported by cvs2svn $ +# Revision 1.5 2002/01/15 00:12:40 richard +# #503340 ] creating issue with [asignedto=p.ohly] +# # Revision 1.4 2002/01/14 07:12:15 richard # removed file writing from tests... #