diff roundup/roundupdb.py @ 3956:bb2722260e47

Fixes from Martin v. Löwis: - Messages created through the web are now given an in-reply-to header when email out to nosy - Nosy messages now include more information about issues (all link properties with a "name" attribute)
author Richard Jones <richard@users.sourceforge.net>
date Tue, 08 Jan 2008 20:55:26 +0000
parents 9997b941dd6d
children 76ee5c3d0ced
line wrap: on
line diff
--- a/roundup/roundupdb.py	Sun Dec 23 01:52:07 2007 +0000
+++ b/roundup/roundupdb.py	Tue Jan 08 20:55:26 2008 +0000
@@ -16,7 +16,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 #
-# $Id: roundupdb.py,v 1.135 2007-11-07 20:47:12 richard Exp $
+# $Id: roundupdb.py,v 1.136 2008-01-08 20:55:26 richard Exp $
 
 """Extending hyperdb with types specific to issue-tracking.
 """
@@ -397,6 +397,39 @@
             if inreplyto:
                 writer.addheader('In-Reply-To', inreplyto)
 
+            # Additional headers for bugs.python.org
+            # 20080106 mvl
+
+            # Generate a header for each link or multilink to
+            # a class that has a name attribute
+            for propname, prop in self.getprops().items():
+                if not isinstance(prop, (hyperdb.Link, hyperdb.Multilink)):
+                    continue
+                cl = self.db.getclass(prop.classname)
+                if not 'name' in cl.getprops():
+                    continue
+                if isinstance(prop, hyperdb.Link):
+                    value = self.get(nodeid, propname)
+                    if value is None:
+                        continue
+                    values = [value]
+                else:
+                    values = self.get(nodeid, propname)
+                    if not values:
+                        continue
+                values = [cl.get(v, 'name') for v in values]
+                values = ', '.join(values)
+                writer.addheader("X-Roundup-%s-%s" % (self.classname, propname),
+                                 values)
+            if not inreplyto:
+                # Default the reply to the first message
+                msgs = self.get(nodeid, 'messages')
+                # Assume messages are sorted by increasing message number here
+                if msgs[0] != nodeid:
+                    inreplyto = messages.get(msgs[0], 'messageid')
+                    writer.addheader('In-Reply-To', inreplyto)
+            # end additional headers
+
             # attach files
             if message_files:
                 part = writer.startmultipartbody('mixed')

Roundup Issue Tracker: http://roundup-tracker.org/