Ticket #598: attachment-description-xmlrpc-1070.patch
| File attachment-description-xmlrpc-1070.patch, 2.1 kB (added by steffenp@gmx.de, 2 years ago) |
|---|
-
ticket.py
old new 27 27 yield ('TICKET_VIEW', ((list, int),), self.listAttachments) 28 28 yield ('TICKET_VIEW', ((xmlrpclib.Binary, int, str),), self.getAttachment) 29 29 yield ('TICKET_APPEND', 30 ((str, int, str, xmlrpclib.Binary, bool),31 (str, int, str, xmlrpclib.Binary)),30 ((str, int, str, str, xmlrpclib.Binary, bool), 31 (str, int, str, str, xmlrpclib.Binary)), 32 32 self.putAttachment) 33 33 yield ('TICKET_ADMIN', ((bool, int, str),), self.deleteAttachment) 34 34 … … 78 78 changeLog.__doc__ = pydoc.getdoc(model.Ticket.get_changelog) 79 79 80 80 def listAttachments(self, req, ticket): 81 """ Lists attachments for a given ticket. """ 82 return [a.filename for a in Attachment.select(self.env, 'ticket', ticket)] 81 """ Lists attachments for a given ticket. Returns [filename, description, size, time, author] 82 for each attachment.""" 83 out = [] 84 for t in Attachment.select(self.env, 'ticket', ticket): 85 out.append((t.filename, t.description or '', t.size, t.time, t.author)) 86 return out 83 87 84 88 def getAttachment(self, req, ticket, filename): 85 89 """ returns the content of an attachment. """ 86 90 attachment = Attachment(self.env, 'ticket', ticket, filename) 87 91 return xmlrpclib.Binary(attachment.open().read()) 88 92 89 def putAttachment(self, req, ticket, filename, d ata, replace=True):93 def putAttachment(self, req, ticket, filename, description, data, replace=True): 90 94 """ Add an attachment, optionally (and defaulting to) overwriting an 91 95 existing one. Returns filename.""" 92 96 if not model.Ticket(self.env, ticket).exists: … … 99 103 pass 100 104 attachment = Attachment(self.env, 'ticket', ticket) 101 105 attachment.author = req.authname or 'anonymous' 106 attachment.description = description 102 107 attachment.insert(filename, StringIO(data.data), len(data.data)) 103 108 return attachment.filename 104 109
