mod_python and xml.sax

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeffrey Froman

    #1

    mod_python and xml.sax

    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.publ isher 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
  • Fredrik Lundh

    #2
    Re: mod_python and xml.sax

    Jeffrey Froman wrote:
    [color=blue]
    >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.publ isher 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.[/color]

    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:



    </F>



    Comment

    • Jeffrey Froman

      #3
      Re: mod_python and xml.sax

      Fredrik Lundh wrote:
      [color=blue]
      > 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.[/color]

      Thank you very much Fredrik, this does seem to be the problem I was having.
      [color=blue]
      > this
      > poster claims to have a fix:
      >
      > http://www.modpython.org/pipermail/m...ay/015569.html[/color]

      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

      Comment

      Working...