Graham Dumpleton
grahamd at dscpl.com.au
Sun May 7 16:38:09 EDT 2006
On 08/05/2006, at 12:39 AM, Jim Gallacher wrote: > Graham Dumpleton wrote: >> On 07/05/2006, at 5:24 PM, Geoff Skerrett wrote: >>> I created a very simple program index.py program to help me >>> understand the >>> behavior. >>> It is as follows; >>> >>> ### Begin index.py >>> >>> def index(req): >>> req.write("I am in index()") >>> def bar(req): >>> req.write("I am in bar()") >> Whoops. Quite obvious really. You must use: >> def index(req): >> return "I am in index()" >> def bar(req): >> return "I am in bar()" >> When you you use req.write(), the headers are automatically >> flushed, so the >> setting of req.content_type by mod_publisher after the published >> function >> returns has no affect. >> In other words, if you are going to use req.write(), you must set >> req.content_type >> yourself. > > Geoff, > > Also, when you are using req.write() directly and not setting the > content_type, you are depending on the browser making a best guess. > You > were getting different results because your browser was not consistent > its guess. The behaviour will differ on various browsers. FWIW. In the case of the directory access, the browser could possibly not have got an opportunity to make a guess, as Apache would have sent back a content type of 'httpd/unix-directory'. If a default content type had been set in Apache configuration, eg, 'text/plain', the other accesses would have returned that automatically. Graham
|