Code

#503340 ] creating issue with [asignedto=p.ohly]
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Tue, 15 Jan 2002 00:12:40 +0000 (00:12 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Tue, 15 Jan 2002 00:12:40 +0000 (00:12 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@549 57a73879-2fb5-44c3-a270-3262357dd7e2

CHANGES.txt
roundup/mailgw.py
roundup/roundupdb.py
test/test_mailgw.py

index d7bc7d698532dce79c205003b554b6b9befda1ef..62e1fedaa32e59832cc13f96772fbbade61005d0 100644 (file)
@@ -25,6 +25,7 @@ Fixed:
  . #503330 ] ANONYMOUS_REGISTER now applies to mail
  . #503353 ] setting properties in initial email
  . #502956 ] filtering by multilink not supported
  . #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
 
 
 2002-01-08 - 0.4.0b1
index 0dc5a737a213a48de39f4977e12a5f22aac4d192..66f91cad054abfd8649b2e21b1e51abcb0907008 100644 (file)
@@ -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. 
 
 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, ';'):
         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:
                 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)
 
 Subject was: "%s"
 '''%(message, subject)
+
+                # ensure it's a valid property name
                 key = key.strip()
                 try:
                     proptype =  properties[key]
                 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)
 
 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):
                 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)
                 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):
                 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):
                         if props.has_key(key):
-                            props[key].append(v)
+                            props[key].append(item)
                         else:
                         else:
-                            props[key] = [v]
+                            props[key] = [item]
 
         #
         # handle the users
 
         #
         # 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'):
 
             # 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']
 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 $
 
 #
 # $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
 #
 # Revision 1.50  2002/01/11 22:59:01  richard
 #  . #502342 ] pipe interface
 #
index 0238be6ae7016c0af728edd07a83e5918cb460af..c2aeafef6fec1129d52186001cbc43c88f815b3a 100644 (file)
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
 # 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.
 
 __doc__ = """
 Extending hyperdb with types specific to issue-tracking.
@@ -461,8 +461,13 @@ class IssueClass(Class):
 
         # list the values
         m = []
 
         # 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)
             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:
             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 $
 
 #
 # $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
 # 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
index cbaf7a5852cc8ec59fdfbd36bf35543fb38d7275..adab1f30b1f8aa0e70d86879703e779763f18df1 100644 (file)
@@ -8,7 +8,7 @@
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 #
 # 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
 
 
 import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys
 
@@ -67,7 +67,7 @@ This is a test submission of a new issue.
 From: Chef <chef@bork.bork.bork
 To: issue_tracker@fill.me.in.
 Message-Id: <dummy_test_message_id>
 From: Chef <chef@bork.bork.bork
 To: issue_tracker@fill.me.in.
 Message-Id: <dummy_test_message_id>
-Subject: [issue] Testing...
+Subject: [issue] Testing... [assignedto=richard]
 
 This is a test submission of a new issue.
 ''')
 
 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.
 
         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...
 Content-Type: text/plain
 Subject: [issue1] Testing...
-To: chef@bork.bork.bork
+To: chef@bork.bork.bork, richard@test
 From: Chef <issue_tracker@fill.me.in.>
 Reply-To: Roundup issue tracker <issue_tracker@fill.me.in.>
 MIME-Version: 1.0
 From: Chef <issue_tracker@fill.me.in.>
 Reply-To: Roundup issue tracker <issue_tracker@fill.me.in.>
 MIME-Version: 1.0
@@ -92,11 +92,18 @@ New submission from Chef <chef@bork.bork.bork>:
 
 This is a test submission of a new issue.
 
 
 This is a test submission of a new issue.
 
+
+----------
+assignedto: richard
+messages: 1
+nosy: Chef, richard
+status: unread
+title: Testing...
 ___________________________________________________
 "Roundup issue tracker" <issue_tracker@fill.me.in.>
 http://some.useful.url/issue1
 ___________________________________________________
 ___________________________________________________
 "Roundup issue tracker" <issue_tracker@fill.me.in.>
 http://some.useful.url/issue1
 ___________________________________________________
-''', 'Generated message not correct')
+''')
 
     def testFollowup(self):
         self.testNewIssue()
 
     def testFollowup(self):
         self.testNewIssue()
@@ -111,7 +118,6 @@ Subject: [issue1] Testing...
 This is a followup
 ''')
         handler = self.instance.MailGW(self.instance, self.db)
 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(),
         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)
 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.
         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'),
 
 def suite():
     l = [unittest.makeSuite(MailgwTestCase, 'test'),
-        unittest.makeSuite(ExtMailgwTestCase, 'test')]
+        unittest.makeSuite(ExtMailgwTestCase, 'test')
+    ]
     return unittest.TestSuite(l)
 
 
 #
 # $Log: not supported by cvs2svn $
     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
 # 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