Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > mod_python and xml.sax

Reply
Thread Tools

mod_python and xml.sax

 
 
Jeffrey Froman
Guest
Posts: n/a
 
      12-20-2004
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
 
Reply With Quote
 
 
 
 
Fredrik Lundh
Guest
Posts: n/a
 
      12-20-2004
Jeffrey Froman wrote:

>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/m...ay/015569.html

</F>



 
Reply With Quote
 
 
 
 
Jeffrey Froman
Guest
Posts: n/a
 
      12-22-2004
Fredrik Lundh wrote:

> 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.

> this
> poster claims to have a fix:
>
> http://www.modpython.org/pipermail/m...ay/015569.html


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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mod_python.so is garbled mod_python.so is garbled blbmdsmith Python 1 12-14-2006 12:15 AM
Python 2.3 and mod_python Ravi Python 0 08-24-2003 12:35 AM
Problem with mod_python and 4Suite Doug Farrell Python 2 08-12-2003 12:21 PM
Mod_Python and ExpatPy David Connell Python 0 07-29-2003 05:01 AM
Apache mod_python and Sessions Markus Schaber Python 7 07-08-2003 05:55 PM



Advertisments