Mercurial > p > roundup > code
changeset 7807:6405bead6f47
doc: document how to set the Content-Type for a template.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 13 Mar 2024 18:16:51 -0400 |
| parents | 4fc89509ce78 |
| children | 6c5f8da9fca7 |
| files | doc/reference.txt |
| diffstat | 1 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/reference.txt Wed Mar 13 17:54:06 2024 -0400 +++ b/doc/reference.txt Wed Mar 13 18:16:51 2024 -0400 @@ -3691,6 +3691,30 @@ developer's guide <developers.html#extracting-translatable-messages>`_ to create the locale files. +Setting the Type of the Returned Data +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Roundup processes a template and uses the name of the template to +determine the Content-Type MIME header that is returned. For +``issue.index.html` it would return ``text/html``. Similarly a file +named ``issue.atom.xml`` (an rss feed) would have a type +of``application/xml``. A file named 'issue.json' would have type +``application/json``. + +However as of Roundup 2.4.0 you can set the type of the file by +calling:: + + request.client.setHeader('Content-Type', 'application/atom+xml') + +from your template. For TAL based templates, something like this:: + + <tal:x tal:replace="python:request.client.setHeader( + 'Content-Type', 'application/atom+xml' + )"/> + +will set the Content-Type header. The header name is case sensitive, +so use capital letters as shown. If you don't you end up with multiple +Content-Type definitions returned to the browser. Displaying Properties ---------------------
