From: richard Date: Tue, 15 Jan 2002 00:12:40 +0000 (+0000) Subject: #503340 ] creating issue with [asignedto=p.ohly] X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=838094f5aba09af85c8413f0f38795bf18d6669e;p=roundup.git #503340 ] creating issue with [asignedto=p.ohly] git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@549 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index d7bc7d6..62e1fed 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -25,6 +25,7 @@ Fixed: . #503330 ] ANONYMOUS_REGISTER now applies to mail . #503353 ] setting properties in initial email . #502956 ] filtering by multilink not supported + . #503340 ] creating issue with [asignedto=p.ohly] 2002-01-08 - 0.4.0b1 diff --git a/roundup/mailgw.py b/roundup/mailgw.py index 0dc5a73..66f91ca 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.51 2002-01-14 02:20:15 richard Exp $ +$Id: mailgw.py,v 1.52 2002-01-15 00:12:40 richard Exp $ ''' @@ -323,6 +323,7 @@ Subject was: "%s" args = m.group('args') if args: for prop in string.split(args, ';'): + # extract the property name and value try: key, value = prop.split('=') except ValueError, message: @@ -332,6 +333,8 @@ Subject argument list not of form [arg=value,value,...;arg=value,value...] Subject was: "%s" '''%(message, subject) + + # ensure it's a valid property name key = key.strip() try: proptype = properties[key] @@ -341,6 +344,8 @@ Subject argument list refers to an invalid property: "%s" Subject was: "%s" '''%(key, subject) + + # convert the string value to a real property value if isinstance(proptype, hyperdb.String): props[key] = value.strip() if isinstance(proptype, hyperdb.Password): @@ -368,23 +373,17 @@ Subject was: "%s" elif isinstance(proptype, hyperdb.Link): link = self.db.classes[proptype.classname] propkey = link.labelprop(default_to_id=1) - try: - props[key] = link.get(value.strip(), propkey) - except: - props[key] = link.lookup(value.strip()) + props[key] = value elif isinstance(proptype, hyperdb.Multilink): - link = self.db.classes[proptype.classname] - propkey = link.labelprop(default_to_id=1) - l = [x.strip() for x in value.split(',')] - for item in l: - try: - v = link.get(item, propkey) - except: - v = link.lookup(item) + # 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() if props.has_key(key): - props[key].append(v) + props[key].append(item) else: - props[key] = [v] + props[key] = [item] # # handle the users @@ -649,10 +648,12 @@ 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'): - try: - assignedto = self.db.user.lookup(props['assignedto']) - except KeyError: - raise MailUsageError, ''' + 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'] @@ -730,6 +731,15 @@ def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'), # # $Log: not supported by cvs2svn $ +# Revision 1.51 2002/01/14 02:20:15 richard +# . changed all config accesses so they access either the instance or the +# config attriubute on the db. This means that all config is obtained from +# instance_config instead of the mish-mash of classes. This will make +# switching to a ConfigParser setup easier too, I hope. +# +# At a minimum, this makes migration a _little_ easier (a lot easier in the +# 0.5.0 switch, I hope!) +# # Revision 1.50 2002/01/11 22:59:01 richard # . #502342 ] pipe interface # diff --git a/roundup/roundupdb.py b/roundup/roundupdb.py index 0238be6..c2aeafe 100644 --- a/roundup/roundupdb.py +++ b/roundup/roundupdb.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundupdb.py,v 1.40 2002-01-14 22:21:38 richard Exp $ +# $Id: roundupdb.py,v 1.41 2002-01-15 00:12:40 richard Exp $ __doc__ = """ Extending hyperdb with types specific to issue-tracking. @@ -461,8 +461,13 @@ class IssueClass(Class): # list the values m = [] - for propname, prop in props.items(): + l = props.items() + l.sort() + for propname, prop in l: value = cl.get(nodeid, propname, None) + # skip boring entries + if not value: + continue if isinstance(prop, hyperdb.Link): link = self.db.classes[prop.classname] if value: @@ -561,6 +566,9 @@ class IssueClass(Class): # # $Log: not supported by cvs2svn $ +# Revision 1.40 2002/01/14 22:21:38 richard +# #503353 ] setting properties in initial email +# # Revision 1.39 2002/01/14 02:20:15 richard # . changed all config accesses so they access either the instance or the # config attriubute on the db. This means that all config is obtained from diff --git a/test/test_mailgw.py b/test/test_mailgw.py index cbaf7a5..adab1f3 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.4 2002-01-14 07:12:15 richard Exp $ +# $Id: test_mailgw.py,v 1.5 2002-01-15 00:12:40 richard 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... +Subject: [issue] Testing... [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 +TO: chef@bork.bork.bork, richard@test Content-Type: text/plain Subject: [issue1] Testing... -To: chef@bork.bork.bork +To: chef@bork.bork.bork, richard@test From: Chef Reply-To: Roundup issue tracker MIME-Version: 1.0 @@ -92,11 +92,18 @@ New submission from Chef : This is a test submission of a new issue. + +---------- +assignedto: richard +messages: 1 +nosy: Chef, richard +status: unread +title: Testing... ___________________________________________________ "Roundup issue tracker" http://some.useful.url/issue1 ___________________________________________________ -''', 'Generated message not correct') +''') def testFollowup(self): self.testNewIssue() @@ -111,7 +118,6 @@ Subject: [issue1] Testing... This is a followup ''') handler = self.instance.MailGW(self.instance, self.db) - # TODO: fix the damn config - this is apalling handler.main(message) self.assertEqual(open(os.environ['SENDMAILDEBUG']).read(), @@ -150,7 +156,6 @@ Subject: [issue1] Testing... This is a second followup ''') handler = self.instance.MailGW(self.instance, self.db) - # TODO: fix the damn config - this is apalling handler.main(message) self.assertEqual(open(os.environ['SENDMAILDEBUG']).read(), '''FROM: roundup-admin@fill.me.in. @@ -180,12 +185,16 @@ class ExtMailgwTestCase(MailgwTestCase): def suite(): l = [unittest.makeSuite(MailgwTestCase, 'test'), - unittest.makeSuite(ExtMailgwTestCase, 'test')] + unittest.makeSuite(ExtMailgwTestCase, 'test') + ] return unittest.TestSuite(l) # # $Log: not supported by cvs2svn $ +# Revision 1.4 2002/01/14 07:12:15 richard +# removed file writing from tests... +# # Revision 1.3 2002/01/14 02:20:15 richard # . changed all config accesses so they access either the instance or the # config attriubute on the db. This means that all config is obtained from