mod_python and xml.sax

J

Jeffrey Froman

I am having difficulty getting mod_python and xml.sax to play nicely with
each other. I am using:

Python 2.4
Mod_python 2.7.10
Apache 1.3.33

Using the mod_python.publisher handler to invoke the go function in the
following script:

from xml.sax import make_parser
def go():
x = make_parser()
return 'OK'

This is the entire script. The import works fine, but creating the parser
fails, producing no traceback, and no Apache errors, but apparently
crashing mod_python. A wget of the URL looks like:

~$ wget http://mysite.com/live/test.py/go
--07:41:51-- http://future.uselesstree.org/live/test.py/go
=> `go'
Resolving mysite.com ... 6x.xxx.xxx.xxx
Connecting to mysite.com[6x.xxx.xxx.xxx]:80... connected.
HTTP request sent, awaiting response...
07:41:51 ERROR -1: No data received.

Changing the import scheme to import the entire xml.sax module, or
attempting to create the parser using xml.sax.parse() produces the same
results: mod_python crashes as soon as an attempt is made to create the
parser.

Searching on the web, I found one other person who claims to have a similar
problem with mod_python 2.7.8 and Python 2.3, but no solutions. Does anyone
here know a fix/workaround for this apparent incompatibility?

Thank you,
Jeffrey
 
F

Fredrik Lundh

Jeffrey said:
I am having difficulty getting mod_python and xml.sax to play nicely with
each other. I am using:

Python 2.4
Mod_python 2.7.10
Apache 1.3.33

Using the mod_python.publisher handler to invoke the go function in the
following script:

from xml.sax import make_parser
def go():
x = make_parser()
return 'OK'

This is the entire script. The import works fine, but creating the parser
fails, producing no traceback, and no Apache errors, but apparently
crashing mod_python.

iirc, both apache and python uses the expat parser; if you don't make sure
that both use the same expat version, you may get into trouble. this poster
claims to have a fix:

http://www.modpython.org/pipermail/mod_python/2004-May/015569.html

</F>
 
J

Jeffrey Froman

Fredrik said:
iirc, both apache and python uses the expat parser; if you don't make sure
that both use the same expat version, you may get into trouble.

Thank you very much Fredrik, this does seem to be the problem I was having.

In fact two fixes are offered in this one short post :) The second fix,
linking Python against the system Expat library, is specifically warned
against in Modules/Setup:

"""
#... Source of Expat 1.95.2 is included in
# Modules/expat/. Usage of a system shared libexpat.so/expat.dll is
# not advised.
"""

So I went with the first fix -- I upgraded the system library to Expat
1.95.8 to match the Expat bundled with Python 2.4 (the excerpt above is
apparently a little outdated). Everything is now working again.

Jeffrey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,829
Latest member
PIXThurman

Latest Threads

Top