mod_python and xml.sax

Discussion in 'Python' started by Jeffrey Froman, Dec 20, 2004.

  1. 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
     
    Jeffrey Froman, Dec 20, 2004
    #1
    1. Advertising

  2. 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/mod_python/2004-May/015569.html

    </F>
     
    Fredrik Lundh, Dec 20, 2004
    #2
    1. Advertising

  3. 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/mod_python/2004-May/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
     
    Jeffrey Froman, Dec 22, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Per Magnus L?vold
    Replies:
    0
    Views:
    1,388
    Per Magnus L?vold
    Nov 15, 2004
  2. Thomas Guetttler
    Replies:
    1
    Views:
    583
    Thomas Guetttler
    Sep 10, 2003
  3. Thomas Guettler

    xml.parsers.expat vs. xml.sax

    Thomas Guettler, Apr 27, 2004, in forum: Python
    Replies:
    2
    Views:
    898
    Martijn Faassen
    Apr 27, 2004
  4. blbmdsmith
    Replies:
    1
    Views:
    651
    Graham Dumpleton
    Dec 14, 2006
  5. Erik Wasser
    Replies:
    5
    Views:
    465
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page