durusmail: quixote-users: Overlaying a static directory
Overlaying a static directory
2005-04-11
2005-04-12
2005-04-12
2005-04-12
2005-04-13
2005-04-13
2005-04-14
2005-04-14
2005-04-14
2005-04-14
2005-04-14
2005-04-14
2005-04-14
2005-04-14
2005-04-14
2005-04-14
David Binger (3 parts)
2005-04-14
2005-04-14
2005-04-13
2005-04-14
2005-04-14
2005-04-13
SCGI util.
2005-04-12
2005-04-13
2005-04-13
2005-04-13
2005-04-13
Overlaying a static directory
mso@oz.net
2005-04-11
I need to overlay a static directory over my application URLs.  I looked
at how QLime did it and made something similar.

    class MyDirectory(Directory):
        _q_exports = ['', 'foo']

        overlay_dir = StaticDirectory('/parent/dir', follow_symlinks=True,
            use_cache=False, cache_time=None, list_directory=False,
            index_filenames=['index.html'])

        def foo(self):
            return "Foo!"

        def _q_lookup(self, name):
            return self.overlay_dir._q_lookup(name)

        def _q_index(self):
             return self.overlay_dir._q_index()

This works well but I'm getting an error with the static pages on Windows
browsers (both IE and Firefox).  When the user clicks on a link or presses
Reload or Shift-Reload, they get an Internal Server Error, or the page
without images, or the proper page.  It keeps on cycling in approximately
that order.  The Apache log says:

[Mon Apr 11 15:22:26 2005] [error] [client XXX.XXX.XXX.XXX] (304)Unknown
error 304: scgi: Unknown error 304: error reading response headers,
referer: https://...

I put a shadow .process_request() in the Publisher to dump the response
info, and these are happening with 200 (OK) responses, not 304 (Not
Modified).  The 304 responses work fine, at least on Linux/Firefox which
is the only browser I can get to do that (and where the problem is not
appearing).

StaticFile publishes a StreamFile (a wrapper around the file object), so I
changed it to return the content as a string.  That didn't help.  I also
tried commenting the response.set_status(304) 'if' block, but that didn't
help either.

I'd like to print the headers and body the webserver is receiving, but the
conversion from Response to HTTP response happens inside scgi.c, and I
don't know enough C to do that.

Strangely, this happens with Windows/IE and Windows/Firefox, but not with
Windows/Netscape (4.77?), Linux/Firefox, Linux/Konqueror, and Mac/Safari.

My application looks like this:
    /appname         - Static pages.
    /appname/db      - Quixote directories.
Originally Quixote was confined to /appname/db/, and outside of that was
Apache static files with Basic Authentication.  Then they decided to use
the Quixote permission system for everything, so I made a new
RootDirectory for /appname with the overlay, and that's when the problem
started occurring.

There's a longer-standing problem with pressing Reload on a dynamic page
and the images disappearing, then reappearing with Shift-Reload.  This may
or may not be related because they are also StaticFiles, but it's
happening on a different set of browsers.  It happens on Linux/Firefox and
several Windows browsers but not on Linux/Konqueror.  This occurs only
with SCGI, not with the simple server.

I tested the application with CGI and it didn't seem to have the problem,
but that takes several seconds to render each item so it's not necessarily
a fair test.

The only solutions I can think of are returning to Basic Authentication
with true static pages, or having Apache proxy to the simple server.  The
latter would presumably be slower since the simple server doesn't do
concurrent requests.  Any other ideas?

-- Mike Orr 



reply