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-25
I had been pleased with a little tweak on StaticFile that enabled me to
insert my site's stock header() and footer() around every plain html
file I had in a html/ directory under my site root.  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.  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.

I'm relatively new to python and much newer to Quixote, so my apologies
if this keenly demonstrates my lack of clue. :(


Here's what had been working in 0.6.1:

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


Then, in my top-level __init__.py, I could just:

for file, path in html_files:
    _q_exports.append(file)
    setattr(this_module, file, MyStaticFile(path, mime_type='text/html'))

...where html_files is from all the *.html paths under $SITEROOT/html.
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.

This was particularly nifty as the header function even spat out a 
tag based on the filename.  It would be simple to wrap the text of
each html in a template, but that loses the ability to update the html
without restarting the server, which was another bonus.  And mostly,
I'd like to understand the recent changes in StaticFile better.

Could anyone kindly suggest a fix, or suggest a better approach?

Many thanks, -Dan


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

</pre></div></div><div class="buttons" style="padding:1ex"><a class="button" href="mailto:daniel.chudnov%40yale.edu?In-Reply-To=20031125225103.GA13524%40curtis.med.yale.edu&Subject=%5BQuixote-users%5D%20MyStaticFile%20%2B%20header/footer%20breaks%20in%200.7a2" title="Reply to ">reply</a></div><div style="margin-right: 1px; float: right"><script type="text/javascript"><!--
google_ad_client = "pub-0093820659847542";
/* 728x90, created 2/28/08 */
google_ad_slot = "7636262811";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></body></html>