Skip to content

Commit 8840e29

Browse files
author
Richard Jones
committed
[SF#503340] creating issue with [asignedto=p.ohly]
1 parent e6fc481 commit 8840e29

File tree

4 files changed

+57
-29
lines changed

4 files changed

+57
-29
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Fixed:
2525
. #503330 ] ANONYMOUS_REGISTER now applies to mail
2626
. #503353 ] setting properties in initial email
2727
. #502956 ] filtering by multilink not supported
28+
. #503340 ] creating issue with [asignedto=p.ohly]
2829

2930

3031
2002-01-08 - 0.4.0b1

roundup/mailgw.py

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class node. Any parts of other types are each stored in separate files
7373
an exception, the original message is bounced back to the sender with the
7474
explanatory message given in the exception.
7575
76-
$Id: mailgw.py,v 1.51 2002-01-14 02:20:15 richard Exp $
76+
$Id: mailgw.py,v 1.52 2002-01-15 00:12:40 richard Exp $
7777
'''
7878

7979

@@ -323,6 +323,7 @@ def handle_message(self, message):
323323
args = m.group('args')
324324
if args:
325325
for prop in string.split(args, ';'):
326+
# extract the property name and value
326327
try:
327328
key, value = prop.split('=')
328329
except ValueError, message:
@@ -332,6 +333,8 @@ def handle_message(self, message):
332333
333334
Subject was: "%s"
334335
'''%(message, subject)
336+
337+
# ensure it's a valid property name
335338
key = key.strip()
336339
try:
337340
proptype = properties[key]
@@ -341,6 +344,8 @@ def handle_message(self, message):
341344
342345
Subject was: "%s"
343346
'''%(key, subject)
347+
348+
# convert the string value to a real property value
344349
if isinstance(proptype, hyperdb.String):
345350
props[key] = value.strip()
346351
if isinstance(proptype, hyperdb.Password):
@@ -368,23 +373,17 @@ def handle_message(self, message):
368373
elif isinstance(proptype, hyperdb.Link):
369374
link = self.db.classes[proptype.classname]
370375
propkey = link.labelprop(default_to_id=1)
371-
try:
372-
props[key] = link.get(value.strip(), propkey)
373-
except:
374-
props[key] = link.lookup(value.strip())
376+
props[key] = value
375377
elif isinstance(proptype, hyperdb.Multilink):
376-
link = self.db.classes[proptype.classname]
377-
propkey = link.labelprop(default_to_id=1)
378-
l = [x.strip() for x in value.split(',')]
379-
for item in l:
380-
try:
381-
v = link.get(item, propkey)
382-
except:
383-
v = link.lookup(item)
378+
# get the linked class
379+
linkcl = self.db.classes[proptype.classname]
380+
propkey = linkcl.labelprop(default_to_id=1)
381+
for item in value.split(','):
382+
item = item.split()
384383
if props.has_key(key):
385-
props[key].append(v)
384+
props[key].append(item)
386385
else:
387-
props[key] = [v]
386+
props[key] = [item]
388387

389388
#
390389
# handle the users
@@ -649,10 +648,12 @@ def handle_message(self, message):
649648

650649
# add assignedto to the nosy list
651650
if properties.has_key('assignedto') and props.has_key('assignedto'):
652-
try:
653-
assignedto = self.db.user.lookup(props['assignedto'])
654-
except KeyError:
655-
raise MailUsageError, '''
651+
assignedto = props['assignedto']
652+
if not re.match('^\d+$', assignedto):
653+
try:
654+
assignedto = self.db.user.lookup(assignedto)
655+
except KeyError:
656+
raise MailUsageError, '''
656657
There was a problem with the message you sent:
657658
Assignedto user '%s' doesn't exist
658659
'''%props['assignedto']
@@ -730,6 +731,15 @@ def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'),
730731

731732
#
732733
# $Log: not supported by cvs2svn $
734+
# Revision 1.51 2002/01/14 02:20:15 richard
735+
# . changed all config accesses so they access either the instance or the
736+
# config attriubute on the db. This means that all config is obtained from
737+
# instance_config instead of the mish-mash of classes. This will make
738+
# switching to a ConfigParser setup easier too, I hope.
739+
#
740+
# At a minimum, this makes migration a _little_ easier (a lot easier in the
741+
# 0.5.0 switch, I hope!)
742+
#
733743
# Revision 1.50 2002/01/11 22:59:01 richard
734744
# . #502342 ] pipe interface
735745
#

roundup/roundupdb.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: roundupdb.py,v 1.40 2002-01-14 22:21:38 richard Exp $
18+
# $Id: roundupdb.py,v 1.41 2002-01-15 00:12:40 richard Exp $
1919

2020
__doc__ = """
2121
Extending hyperdb with types specific to issue-tracking.
@@ -461,8 +461,13 @@ def generateCreateNote(self, nodeid):
461461

462462
# list the values
463463
m = []
464-
for propname, prop in props.items():
464+
l = props.items()
465+
l.sort()
466+
for propname, prop in l:
465467
value = cl.get(nodeid, propname, None)
468+
# skip boring entries
469+
if not value:
470+
continue
466471
if isinstance(prop, hyperdb.Link):
467472
link = self.db.classes[prop.classname]
468473
if value:
@@ -561,6 +566,9 @@ def generateChangeNote(self, nodeid, oldvalues):
561566

562567
#
563568
# $Log: not supported by cvs2svn $
569+
# Revision 1.40 2002/01/14 22:21:38 richard
570+
# #503353 ] setting properties in initial email
571+
#
564572
# Revision 1.39 2002/01/14 02:20:15 richard
565573
# . changed all config accesses so they access either the instance or the
566574
# config attriubute on the db. This means that all config is obtained from

test/test_mailgw.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# but WITHOUT ANY WARRANTY; without even the implied warranty of
99
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1010
#
11-
# $Id: test_mailgw.py,v 1.4 2002-01-14 07:12:15 richard Exp $
11+
# $Id: test_mailgw.py,v 1.5 2002-01-15 00:12:40 richard Exp $
1212

1313
import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys
1414

@@ -67,7 +67,7 @@ def testNewIssueAuthMsg(self):
6767
From: Chef <[email protected]
6868
6969
Message-Id: <dummy_test_message_id>
70-
Subject: [issue] Testing...
70+
Subject: [issue] Testing... [assignedto=richard]
7171
7272
This is a test submission of a new issue.
7373
''')
@@ -78,10 +78,10 @@ def testNewIssueAuthMsg(self):
7878

7979
self.assertEqual(open(os.environ['SENDMAILDEBUG']).read(),
8080
81-
81+
TO: [email protected], richard@test
8282
Content-Type: text/plain
8383
Subject: [issue1] Testing...
84-
84+
To: [email protected], richard@test
8585
From: Chef <[email protected].>
8686
Reply-To: Roundup issue tracker <[email protected].>
8787
MIME-Version: 1.0
@@ -92,11 +92,18 @@ def testNewIssueAuthMsg(self):
9292
9393
This is a test submission of a new issue.
9494
95+
96+
----------
97+
assignedto: richard
98+
messages: 1
99+
nosy: Chef, richard
100+
status: unread
101+
title: Testing...
95102
___________________________________________________
96103
"Roundup issue tracker" <[email protected].>
97104
http://some.useful.url/issue1
98105
___________________________________________________
99-
''', 'Generated message not correct')
106+
''')
100107

101108
def testFollowup(self):
102109
self.testNewIssue()
@@ -111,7 +118,6 @@ def testFollowup(self):
111118
This is a followup
112119
''')
113120
handler = self.instance.MailGW(self.instance, self.db)
114-
# TODO: fix the damn config - this is apalling
115121
handler.main(message)
116122

117123
self.assertEqual(open(os.environ['SENDMAILDEBUG']).read(),
@@ -150,7 +156,6 @@ def testFollowup2(self):
150156
This is a second followup
151157
''')
152158
handler = self.instance.MailGW(self.instance, self.db)
153-
# TODO: fix the damn config - this is apalling
154159
handler.main(message)
155160
self.assertEqual(open(os.environ['SENDMAILDEBUG']).read(),
156161
@@ -180,12 +185,16 @@ class ExtMailgwTestCase(MailgwTestCase):
180185

181186
def suite():
182187
l = [unittest.makeSuite(MailgwTestCase, 'test'),
183-
unittest.makeSuite(ExtMailgwTestCase, 'test')]
188+
unittest.makeSuite(ExtMailgwTestCase, 'test')
189+
]
184190
return unittest.TestSuite(l)
185191

186192

187193
#
188194
# $Log: not supported by cvs2svn $
195+
# Revision 1.4 2002/01/14 07:12:15 richard
196+
# removed file writing from tests...
197+
#
189198
# Revision 1.3 2002/01/14 02:20:15 richard
190199
# . changed all config accesses so they access either the instance or the
191200
# config attriubute on the db. This means that all config is obtained from

0 commit comments

Comments
 (0)