durusmail: quixote-users: MyStaticFile + header/footer breaks in 0.7a2
MyStaticFile + header/footer breaks in 0.7a2
MyStaticFile + header/footer breaks in 0.7a2
daniel.chudnov@yale.edu
2003-11-26
Neil Schemenauer wrote, on Tue, Nov 25, 2003 at 06:15:56PM -0500:
>
> Well, Quixote is meant to be flexible so you're forgiven. :-)

Phew! :)


> More efficient would be to use TemplateIO.  Something like:
>
>         r = TemplateIO(html=1)
>         file_name = request.get_path()[1:]     # drop leading '/'
>         r += header(get_title_from_path(file_name))
>         body = StaticFile.__call__(self, request)
>         if isinstance(body, Stream):
>             for hunk in body:
>                 r += hunk
>         else:
>             r += body
>         r += footer()
>       return r.getvalue()
>
> Untested code of course.

Works, when the hunks and body appended to r are wrapped in htmltext()s,
or, rather, if the TemplateIO has html=0.  The latter seems better,
and probably safe enough sans htmltext(), as this content should never
be dynamic or user-supplied.  Famous last words, maybe.

Also, as you suggested, there is something odd happening with caching
and mozilla on this site, and maybe it's related.  Will investigate
further... but this is working as desired for now, and the oddness
was there before this came up.

Thanks for responding so quickly.


  -Dan


--
Daniel Chudnov
Yale Center for Medical Informatics
(203) 737-5789

reply