[mod_python] Http Response None - Page renders as Text

Thimios Katsoulis thkatsou at yahoo.gr
Sat Oct 28 06:40:05 EDT 2006

Hello all.
I am developing a site in mod_python and I am facing a
The nasty thing is that this problem does not occur
all the time . 
The problem is that firefox renders the  page and
displays it as text . So what you see is the html
source and not the rendered page.
This problem occurs once in many times . When you hit
refresh the page renders normally.
I have set content_type to "text/html".
Here is the problematic output as seen on firefox:

NoneHTTP/1.1 200 OK
Date: Sat, 28 Oct 2006 10:13:32 GMT
Server: Apache/2.0.55 (Ubuntu) mod_python/3.1.4
Python/2.4.3 PHP/5.1.2
Content-Length: 1974
Keep-Alive: timeout=15, max=95
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8


<html xmlns="http://www.w3.org/1999/xhtml"


and the html source continues.

If you hit refresh , I repeat , page renders normally.
This behaviour is seen on a 1.0.8 firefox on Suse
linux 10.0 on a machine on my local lan.
The test web server is also on my local lan and is
Ubuntu 6.0.6 with mod_python/3.1.4 as you can notice
on the header.
Please notice also the first line of the output
"NoneHTTP/1.1 200 OK" .

Here are the settings of the site :
<VirtualHost *>
        ServerAdmin webmaster at localhost
        ServerName www.evropi.com
        DocumentRoot /var/www/evropi
        <Directory /var/www/evropi>
                Options None
                AllowOverride All
                Order allow,deny
                allow from all

                SetHandler mod_python
                PythonHandler start
                PythonDebug On


        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info,
notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        ServerSignature On

Please notice also that this is not a real domain name
It's just used for development . I am testing a site
by modyfing my local lan's machine's /etc/hosts files.

Here is the start.py python script :
import time
from mod_python import apache
def handler(req):
        req.content_type = "text/html"
        from lib import SiteBuilder
        #req.write("%f" % (diff))
        req.content_type = "text/html"

        return apache.OK


I have noticed this behaviour from other pc's as well
, mostly on Firefox.
But this does not happen all the times , it is
something random , and as a developer I consider
random problem occuring very nasty .
Anyone has seen this behaviour before ? 
Should I send http headers before calling req.write()?
I 'll appreciate any help .

Thimios Katsoulis


Χρησιμοποιείτε Yahoo!; 
Βαρεθήκατε τα ενοχλητικά μηνύματα (spam); Το Yahoo! Mail 
διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών 
μηνυμάτων http://login.yahoo.com/config/mail?.intl=gr 

More information about the Mod_python mailing list