[mod_python] mod_python 2.7.8 broken on python2.3?

Alexander Neumann modpython at lists.bumpern.de
Thu Oct 16 23:19:52 EST 2003


Hi,

I just started having a look at mod_python, it looks really great, but
there are a few strange exceptions thrown at points where (IMHO) no
exception should be raised.

For example if I'm using this file (test.py):
=======
from mod_python import apache

def test(req):
    return "just a test\n"
=======


Calling the test-function directly works as expected:
$ dog --no-header http://localhost/~fd0/test/test
just a test


Calling only the file fails and throws a 404:
$ dog --no-header http://localhost/~fd0/tlis/test
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>404 Not Found</TITLE>
</HEAD><BODY>
<H1>Not Found</H1>
The requested URL /~fd0/tlis/test was not found on this server.<P>
<HR>
<ADDRESS>Apache/1.3.28 Server at localhost Port 80</ADDRESS>
</BODY></HTML>


But if the URL ends with a slash ("/"), an exception is thrown and I
don't know if that's the normal behaviour (I would expect a 404, just
like the example above):
$ dog --no-header http://localhost/~fd0/tlis/test/
Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 193, in Dispatch
    result = object(req)

  File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line 88, in handler
    if func_path[-1] == ".":

IndexError: string index out of range




Another problem is using the file (example.py):
======
__auth_realm__ = "Members only"


def hello(req):
    def __auth__(req, user, passwd):
        if user == "eggs" and passwd == "spam" or \
           user == "joe" and passwd == "eoj":
            return 1
        else:
            return 0

    def __access__(req, user):
        if user == "joe":
            return 1
        else:
            return 0

    return 'hello<br><a href="logout?username=%s"> logout </a>' % req.connection.user

def logout(req, username=""):
    def __auth__(req, user, passwd):
        if not username == "":
            return 0
        else:
            return 1
    return '<a href="hello"> test it! </a>'
======


Calling the logout function throws an exception, too:
$ dog --no-header http://localhost/~fd0/tlis/example/logout
Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 193, in Dispatch
    result = object(req)

  File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line 135, in handler
    object = resolve_object(req, module, func_path, realm, user, passwd)

  File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line 296, in resolve_object
    user, passwd)

  File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line 224, in process_auth
    __auth__ = new.function(__auth__, globals())

TypeError: arg 5 (closure) must be tuple




Is this a bug or a feature?


- Alexander

-- 
"Good luck... The only good thing about being compromised is that it
makes you more paranoid about being on the net."
 - Jamie Lawrence on debian-security
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.modpython.org/pipermail/mod_python/attachments/20031016/22b82c8e/attachment-0003.bin


More information about the Mod_python mailing list