[mod_python] options to suppress error when accessing module directly with Publisher

azurIt azurit at pobox.sk
Fri Mar 4 01:59:29 EST 2005


hi,

i already reported this bug (but not received an answer
yet..) and it can be easily fixed. just edit publisher.py,
find this code:
    if func_path[-1] == ".":
        func_path = func_path[:-1]

    # if any part of the path begins with "_", abort
    if func_path[0] == '_' or string.count(func_path, "._"):
        raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND

and and replace it with this:
    if func_path != "" and func_path[-1] == ".":
        func_path = func_path[:-1]

    # if any part of the path begins with "_", abort
    if func_path != "":
        if func_path[0] == '_' or string.count(func_path,
"._"):
            raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND



and there is also another bug. when you will try to refer to a
function in non-existing script, you will get ImportError, for
example http://192.168.0.1/non-existing-script/anything-here .
this can be easily fixed too:

find this:
    module = apache.import_module(module_name, _req, [path])

replace with this:
    try:
        module = apache.import_module(module_name, _req,
[path])
    except ImportError:
        raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND


these bugs probably 'works' only in 2.7.x

azurIt


> Graham Dumpleton wrote:
> > Yep, you must be using mod_python 2.7.X as there I get:
> 
> I am. I'm sorry I didn't test it on my 3.1 installation,
where it works  > as expected. I made a wrong assumption when I
glanced at the current  > docs for info on Publisher traversal:
> 
>  
http://www.modpython.org/live/current/doc-html/hand-pub-alg-trav.html > 
> It turns out that this example refers to the module *and*
function,  > which are both named index:
> 
>   http://www.somehost/index/ will return "We are in index()"
> 
> Thanks for pointing out the 3.1 behaviour.
> 
> > This is one of the benefits of having publisher code which
is outside   > > of the main
> > release. It can be made to work the same with both 2.7.X
and 3.1.X   > > versions of mod_python
> > and you don't have to suffer the fact that such bugs in
2.7.X will most   > > likely never
> > be fixed.
> 
> True, but I'm revamping the site in preparation for upgrading
to apache  > 2.x/mod_python 3.x, where it won't be an issue.
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
> 

____________________________________
EPI.sk Zbierka zakonov a uplne znenia online.
Zakony, vyhlasky, nariadenia, denna aktualizacia.
Najdete na stranke http://www.epi.sk/zbierka.htm




More information about the Mod_python mailing list