[mod_python] Mod_python with ORM

Morten Feldthaus morten at feldthaus.dk
Sun Oct 9 04:27:28 EDT 2005


I'm having some problems with mod_python and a ORM that i'm using.

The script works only in CLI. Mod_python has serious problems with it.
I have to disable keep-alive in Apache, otherwise will the connection
be broken.

This is what happenes with keep-alive on:
mim at gorilla:~$ w3c http://localhost/ace
Looking up localhost
Looking up localhost
Contacting localhost
Reading...
Waaaa
Contacting localhost
Read 1Kbytes
/build/buildd/w3c-libwww-5.4.0/Library/src/HTTChunk.c:55 Chunk decoder
received illigal chunk size: `\uffff'
Afbrudt (SIGABRT)

With keep-alive off:
mim at gorilla:~$ w3c http://localhost/ace
Looking up localhost
Looking up localhost
Contacting localhost
Reading...
Waaaa

w3c was the only browser where I actually could see what happened. In
firefox it simply wouldn't load anything. No error message, it just
kept showing the last page.

Here's the code:

from orm.datasource import datasource
from orm.dbclass import dbclass
from orm.adapters.pgsql.columns import *

ds = datasource(adapter="mysql", password="mypassword", user="root",
host="localhost", db="py", debug = 1)

class user(dbclass):
	columns = { "id" : serial(),
			  }

""" For testing in CLI """
try:
    from mod_python import apache
except:
    print ("Weeee")
    res = ds.select(user).fetchall(),
    print res
    print ("Woooo")

def handler(req):
    req.content_type = "text/html"
    req.write("Waaaa\n")
    res = ds.select(user).fetchall(),
    req.write(res)
    req.write("Wuuuu\n")

    return apache.OK

---end---

In the browser the only thing displayed is "Waaaa". In CLI I get the
following output
mim at gorilla:/var/www$ python ace.py
Weeee
([<user (pyid=-1216130516 oid=1 id=1L)>],)
Woooo

Do you guys have any suggestions/thoughts?

--
Morten Feldthaus



More information about the Mod_python mailing list