Firat KUCUK wrote ..
> Graham Dumpleton yazmýþ:
> >What is the actual problem you are trying to solve?
> >
> >The "len(req.path_info) > 0" is actually redundant because when
> >req.path_info is a string and has length 0, the "req.path_info"
> >boolean check will fail anyway.
> >
> >In other words, the change you made wouldn't make any difference
> >that I can see to the actual outcome. Is the redundancy all you
> >were wanting to point out???
> >
> >BTW, you should be careful about what SCRIPT_NAME gets set
> >to by Apache and by this code. See discussion of strange things
> >that happen at:
> >
> >  https://issues.apache.org/jira/browse/MODPYTHON-68
>
> briefly:
>
> print len(None)
>
> TypeError: len() of unsized object
>
>
> if we use:
>
> if req.path_info *and* len(req.path_info) > 0:
>
> the same error will be occur.
>
> please try
> DirectoryIndex index.py
> and use cgihandler.
>
> req.path_info will be None.
> and we cannot calculate length of none object

If req.path_info is None, the RHS of the "and" is not executed
so len() is never performed on a None object.

Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> path_info = None
>>> if path_info and len(path_info):
..   print "hi"
..
>>> path_info = ""
>>> if path_info and len(path_info):
..   print "hi"
..
>>>

I really can't see how this can be a source of a problem.

I had already written a separate test handler to check.

  AddHandler mod_python .py
  PythonHandler index
  PythonDebug On

  DirectoryIndex index.py

  # ---

  from mod_python import apache

  def handler(req):
    req.content_type = 'text/plain'
    req.write("%s\n"%req.path_info)
    req.write("%s\n"%apache.build_cgi_env(req))
    return apache.OK

Output shows:

  None
  {......,  'SCRIPT_NAME': '/~grahamd/script_name/index.py', 'REQUEST_URI': 
'/~grahamd/script_name/', ......}

No error occurred.

If you are getting an actual error of some sort, then post what
the full traceback is, as at the moment this isn't making a great
deal of sense to me.

Graham

Reply via email to