On Wed, Oct 18, 2006 at 12:45:50PM +1300, Andrew Groom wrote:
> FB wrote:
> >On Tue, Oct 17, 2006 at 12:53:48PM +1300, Andrew Groom wrote:
> >>Hi All,
> >>I want to do something that feels like it should be really simple: set a
> >>specific content type when a particular resource is published (a Firefox
> >>extension, a binary .xpi file if it helps). Any ideas how I could do
> >>that ?
> >You should do this in the __call__() method. This is the default view of an
> >advanced IFile implementation of mine:
> >class AutoFileView(BrowserView):
> > def __call__(self):
> > self.request.response.setHeader('Content-Type',
> > self.context.contentType)
> > self.request.response.setHeader('Content-Length',
> > self.context.getSize())
> > return self.context.data
> Thanks, Frank. The bit I'm missing now is the ZCML to hook it all together.
> Do I use a
> browser:resource ? If you could give me an example, that'd be great.
No - it's a simple BrowserView. Just use a standard-page-statement:
BTW: browser:resource is used for 100% static content (CSS-files, icons,
Zope3-users mailing list