[Zope] ZPublishing
Amos Latteier
amos@aracnet.com
Wed, 29 Sep 1999 23:10:14 -0700
At 06:07 PM 9/29/99 +1000, you wrote:
>I am trying to send some dynamically generated binary data to the output
>buffer. How do I do it in python with Zope?
>
>As I understand it HTMLFile(xxxx) returns a dtml document object. I
>could dump the data to file and then try to send it using the binary
>equivalent of the HTMLFile class. Is there such an animal?
>
>I noticed there is the ImageFile class, but the guess_encoding module
>does not list the content type I need to publish. Is it a good idea to
>add mine there or can I override this?
>
>Isn't there anyway I could just write to the output buffer?
The normal case is to just create a file object and manually enter the
mime-type (called 'Content-type') in the edit form.
If you are generating different binary data with an external method, just
return it, and perhaps set some HTTP headers like so:
def myDynamicContent(self, RESPONSE):
"return dynamic binary data"
# generate data
RESPONSE.setHeader('content-type', 'foo/bar') # or whatever
return data
If you want to do this from DTML I think that you can use the return tag,
or use RESPONSE.write.
<dtml-call "RESPONSE.setHeader('content-type', 'foo/bar')">
<dtml-return data>
or
<dtml-call "RESPONSE.setHeader('content-type', 'foo/bar')">
<dtml-call "RESPONSE.write(data)">
Hope this helps.
-Amos