The following will download the messages spool for an issue as an mbox file. It's intended to be dropped into the extensions directory of a 0.8 or later tracker. It'll work with 0.7, but the registration interface has changed (the init bit at the end is 0.8-or-later).
The code:
from roundup.cgi.actions import Action
class MboxAction(Action):
def handle(self):
if self.classname != 'issue':
raise ValueError, 'Can only download messages mbox for issues'
if self.nodeid is None:
raise ValueError, 'Can only download messages mbox for single issues'
r = []
a = r.append
msg = self.db.msg
user = self.db.user
for msgid in self.db.issue.get(self.nodeid, 'messages'):
author = msg.get(msgid, 'author')
date = msg.get(msgid, 'date')
sdate = date.pretty('%a, %d %b %Y %H:%M:%S +0000')
a('From %s %s'%(user.get(author, 'address'), sdate))
a('From: %s'%user.get(author, 'address'))
a('Message-Id: %s'%msg.get(msgid, 'messageid'))
inreplyto = msg.get(msgid, 'inreplyto')
if inreplyto:
a('In-Reply-To: %s'%inreplyto)
body = msg.get(msgid, 'content').splitlines()
for line in range(len(body)):
if body[line].startswith('From '):
body[line] = '>'+body['line']
a(body[line])
a('\n')
h = self.client.additional_headers
h['Content-Type'] = 'application/mbox'
self.client.header()
if self.client.env['REQUEST_METHOD'] == 'HEAD':
# all done, return a dummy string
return 'dummy'
return '\n'.join(r)
def init(tracker):
tracker.registerAction('mbox', MboxAction)
-- RichardJones
The usage bit --wiki, Sat, 29 Jul 2006 11:12:31 +1000 reply
To use it, I created a link:
Download
(should work fine in the issue.item.html template)
... --wiki, Sat, 29 Jul 2006 11:14:43 +1000 reply
One more try: <a href="#" tal:attributes="href string:issue${context/id}?@action=mbox" i18n:translate="">Download</a>