Closed wosc closed 4 years ago
I'm not sure how broadly useful that would be. In your example, I wouldn't use a generic "bytes" renderer because I'd want the Content-Type to be text/xml
.
I agree that returning bytes is not enough. We'd have to define a default content type like application/octet-stream
, etc. It's really best to do this with your own adapter because I don't see how we'd apply it generally to everyone at the framework level.
In general if I were ever doing this, my app would be doing return Response(...)
from within the view itself because it seems unlikely you'd want to use this pattern across too many views.
OK fair enough. Thanks!
For example, when serializing XML, I might already have bytes (and furthermore,
lxml.etree.tostring(doc, encoding='unicode', xml_declaration=True)
(rightly) refuses to generate an XML declaration, so I'd have to tack that on manually, just to keep everything in text land).I'm currently declaring support for this explicitly in my application like so,
which of course works just fine. But I think it would make sense for Pyramid to support this out of the box. Or am I missing something here?