ZSI + mod_python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • exhuma.twn

    #1

    ZSI + mod_python

    Hi,

    I tried for the last 2 hours now to somehow grasp how to use ZSI over
    mod_python. It's nice that they have a code-example in the ZSI docs,
    but it's incomplete and you are left guessing.

    The ZSI docs I used as reference can be found on http://
    pywebsvcs.sourc eforge.net/zsi.html#SECTIO N00313000000000 0000000

    Here is where I am at so far:

    First I created the two files as described in the ZSI docs. Namely
    "MyHandler. py" and "ws.py". The first name is obvious to someone who
    has coded at least a little bit of python, but it could be explicitly
    stated in the docs, so the beginners don't get stumped by a silly
    filename to start with ;)
    The second filename is my own concoction. I suppose it does not matter
    how it's named as you specify it in the apache conf anyhow.

    So. Now to the apache conf. I put the scripts into the document-root
    of my server. In this case: "/var/www/localhost". So this is what I
    get (ommitting the unnecessary cruft -- marked it with "[...]"):

    ---- /etc/apache2/sites-enables/000-default.conf
    -----------------------------------
    <VirtualHost *>
    [...]
    DocumentRoot /var/www/localhost
    AddHandler mod_python .py
    [...]
    <Directory /var/www/localhost/>
    [...]
    PythonHandler ws
    PythonDebug On
    </Directory>
    [...]
    --------------------------------------------------------------------------------------------------------

    This is as far as I got. Now how do I call a service from this
    setting? What's the URI I need to specify in the client?

    I was trying "http://server/foo.py" in the browser, and it was
    obviously doing *something* with the "ws.py" file. But I have no clue
    what. Here's the output:

    ---- Browser output for http://server/foo.py
    ---------------------------------------------
    Mod_python error: "PythonHand ler ws"

    Traceback (most recent call last):

    File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line
    299, in HandlerDispatch
    result = object(req)

    File "/var/www/localhost/ws.py", line 9, in handler
    dispatch.AsHand ler(modules=(My Handler,), request=req)

    File "/usr/lib/python2.4/site-packages/ZSI-2.0_rc3-py2.4.egg/ZSI/
    dispatch.py", line 263, in AsHandler

    File "/usr/lib/python2.4/site-packages/ZSI-2.0_rc3-py2.4.egg/ZSI/
    parse.py", line 61, in __init__

    File "/usr/lib/python2.4/site-packages/PyXML-0.8.4-py2.4-linux-
    i686.egg/_xmlplus/dom/ext/reader/PyExpat.py", line 65, in fromStream
    success = self.parser.Par seFile(stream)

    ExpatError: no element found: line 1, column 0
    --------------------------------------------------------------------------------------------------------


    No matter what I append to the URI, it does not make a difference in
    the output. And *why* am I forced to add a "abracadabra.py " to the
    URI? Could I not set Apache up in a way that it would use the ZSI
    handler for everything that calls -- let's say -- http://
    webservices.ser ver.tld/ instead of http://webservices.server.tld/
    booh.py ?

    I'm off to a little bit more of testing. But any hints/input would be
    kindly appreciated ;)

Working...