[Zope] Re: GoLive and WebDAV
Dieter Maurer
dieter@handshake.de
Mon, 2 Apr 2001 20:50:51 +0200 (CEST)
Jeffrey P Shell writes:
> DTML Methods themselves don't know that this is set until render time, so
> the content type WebDAV property never quite works with them. I *believe*
> ZPT should be architected to handle this issue better, but DTML Methods
> never were.
It is quite easy to make DTML Methods "Content-Type" aware:
Give it a "content_type" attribute. All the machinery is present
to provide the correct Content-Type HTTP header, as soon
as there is a "content_type" attribute.
The following two external methods can manage a "content_type"
attribute of DTMLMethods (for DTMLDocuments, a standard
property works well).
def getContentType(obj):
'''return content type of *obj*, 'None', if not available.'''
o= getattr(obj,'aq_base',obj)
return getattr(o,'content_type',None)
def setContentType(obj,type):
'''set content type of *obj* to *type*.'''
o= getattr(obj,'aq_base',obj)
o.content_type= type
An alternative is to give the DTMLMethod's extensions.
If, e.g., a DTMLMethod has an id with a '.txt" extension (suffix),
then its default content type is "text/plain".
Dieter