Skip to content

Commit a8a2610

Browse files
committed
doc: document how to set the Content-Type for a template.
1 parent 56df0e4 commit a8a2610

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

doc/reference.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3691,6 +3691,30 @@ create you'll need to add new locale files in the tracker home under a
36913691
developer's guide <developers.html#extracting-translatable-messages>`_ to
36923692
create the locale files.
36933693

3694+
Setting the Type of the Returned Data
3695+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3696+
3697+
Roundup processes a template and uses the name of the template to
3698+
determine the Content-Type MIME header that is returned. For
3699+
``issue.index.html` it would return ``text/html``. Similarly a file
3700+
named ``issue.atom.xml`` (an rss feed) would have a type
3701+
of``application/xml``. A file named 'issue.json' would have type
3702+
``application/json``.
3703+
3704+
However as of Roundup 2.4.0 you can set the type of the file by
3705+
calling::
3706+
3707+
request.client.setHeader('Content-Type', 'application/atom+xml')
3708+
3709+
from your template. For TAL based templates, something like this::
3710+
3711+
<tal:x tal:replace="python:request.client.setHeader(
3712+
'Content-Type', 'application/atom+xml'
3713+
)"/>
3714+
3715+
will set the Content-Type header. The header name is case sensitive,
3716+
so use capital letters as shown. If you don't you end up with multiple
3717+
Content-Type definitions returned to the browser.
36943718

36953719
Displaying Properties
36963720
---------------------

0 commit comments

Comments
 (0)