On Tue, Nov 25, 2003 at 05:51:03PM -0500, daniel.chudnov@yale.edu wrote:
> I know Quixote isn't geared toward separation-of-skills
> development, but it was a convenient way to allow a non-coder to
> write up an arbitrary number of docs in simple html and quickly
> load/update them on the site.
Well, Quixote is meant to be flexible so you're forgiven. :-)
> The tweak breaks in 0.7a2 (scgi-1, apache-2.0.40), apparently
> because StaticFile now returns a FileStream, and I'm not sure how
> to fix my code.
You should be able to use:
''.join(some_stream)
to convert a stream to a string. I'm not sure but maybe Stream
should have a __str__ method that does that. OTOH, calling str()
does not work well if htmltext is involved.
> class MyStaticFile (StaticFile):
> def __call__(self, request):
> contents = htmltext('')
> if self.mime_type == 'text/html':
> file_name = request.get_path()[1:] # drop leading '/'
> contents += header(get_title_from_path(file_name))
> contents += htmltext(StaticFile.__call__(self, request))
> contents += footer()
> return contents
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.
> With 0.7a2 any mozilla-1.5 calls to the html files hang, unless I
> shift-reload, which results in a header-and-footer-only page, i.e. with
> none of the appropriate page's html inserted between the header and
> footer.
That could be a caching issue. You might want to temporarily hack
StaticFile to not use any caching while you are debugging.
Neil