# HG changeset patch # User Paul Boddie # Date 1340567843 -7200 # Node ID 635de7896589517cde6aa320a742d4bbaa27d298 # Parent 3ca98b7e975bcf4554ef29665480d80085281300 Restructured the response writing to use a single write invocation per item. diff -r 3ca98b7e975b -r 635de7896589 actions/SharedUpdates.py --- a/actions/SharedUpdates.py Sun Jun 17 01:31:39 2012 +0200 +++ b/actions/SharedUpdates.py Sun Jun 24 21:57:23 2012 +0200 @@ -151,10 +151,6 @@ fragment_link = "%s?action=ShowUpdate&fragment=%s" % (link, fragment) - request.write('\r\n') - request.write('%s\r\n' % escape(summary)) - request.write('%s\r\n' % escape(fragment_link)) - # Get the types available for the fragment. # This uses an extended parser API method if available. @@ -164,17 +160,34 @@ else: mimetypes = ["text/html"] + # NOTE: Perform content negotiation, obtaining mimetypes common to the + # NOTE: fragment and the client. + + download_links = [] + for mimetype in mimetypes: specific_link = "%s&mimetype=%s" % (fragment_link, mimetype) - request.write('\r\n' % ( + download_links.append('' % ( escattr(mimetype), escattr(specific_link))) # NOTE: Could potentially get a summary for the fragment. # NOTE: The published and updated details would need to be deduced from # NOTE: the page history. - request.write('\r\n') + d = { + "title" : escape(summary), + "fragment_link" : escape(fragment_link), + "download_links" : "\r\n".join(download_links), + } + + request.write('''\ +\r +%(title)s\r +%(fragment_link)s\r +%(download_links)s\r +\r +''' % d) request.write('\r\n')