Issue Details (XML | Word | Printable)

Key: MODPYTHON-63
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Graham Dumpleton
Reporter: Kevin Quick
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
mod_python

Handle wildcard in Directory to sys.path transfer

Created: 14/Jul/05 08:35 AM   Updated: 02/Apr/07 11:23 AM
Return to search
Component/s: core
Affects Version/s: 3.1.3
Fix Version/s: 3.3.1

Time Tracking:
Not Specified

Environment: gentoo Linux 2.4.20-gentoo-r8 apache-2.0.54-r8 mod_python-3.1.3-r1

Resolution Date: 25/Aug/06 01:03 AM


 Description  « Hide
Below is a patch that does two things:

1) On module import failures, logfile contains additional information showing
   system paths as well as module name.

2) Support of Python*Handler found in a wildcard-based directory. For example,

<IfModule mod_python.c>
    <Directory /home/*/public_html/python>
        AddHandler mod_python .py
        PythonHandler helloworld
        PythonDebug on
    </Directory>
</IfModule>

which mirrors a corresponding perl setting and would allow the user to
place a mod_python handler in their $HOME/public_html/python directory.

In the current code, the wildcard is not translated, the sys.path update
will be invalid, and the user's module will not be accessible. The attached
patch provides a fix for this.

N.B. There are obvious security issues in using this type of configuration,
but this is very useful for dev environments, and security would implemented
via explicit alternatives anyhow.

Index: apache.py
===================================================================
RCS file: /home/cvspublic/httpd-python/lib/python/mod_python/apache.py,v
retrieving revision 1.83
diff -r1.83 apache.py
33a34,40
> def add_handler_path(hpath):
> import glob
> if hpath:
> for D in glob.glob(hpath):
> if os.path.isdir(D) and D not in sys.path:
> sys.path.insert(0, D)
>
170,171c177
< if filter.dir and (filter.dir not in sys.path):
< sys.path[:0] = [filter.dir]
---
> add_handler_path(filter.dir)
280,282c286
< dir = hlist.directory
< if dir and (dir not in sys.path):
< sys.path[:0] = [dir]
---
> add_handler_path(hlist.directory)
454c458,462
< f, p, d = imp.find_module(parts[i], path)
---
> try:
> f, p, d = imp.find_module(parts[i], path)
> except:
> _apache.log_error("mod_python: import error for module %s with path: %s and sys.path: %s"%(parts[i],path,sys.path))
> raise


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Nicolas Lehuen made changes - 22/Oct/05 04:03 PM
Field Original Value New Value
Component/s core [ 11607 ]
Graham Dumpleton made changes - 09/Apr/06 02:18 PM
Assignee Graham Dumpleton [ grahamd ]
Graham Dumpleton made changes - 09/Apr/06 02:18 PM
Status Open [ 1 ] In Progress [ 3 ]
Graham Dumpleton made changes - 07/May/06 07:32 AM
Status In Progress [ 3 ] Open [ 1 ]
Graham Dumpleton made changes - 30/Jul/06 10:55 AM
Status Open [ 1 ] In Progress [ 3 ]
Graham Dumpleton made changes - 13/Aug/06 07:52 AM
Fix Version/s 3.3 [ 12310101 ]
Graham Dumpleton made changes - 25/Aug/06 01:03 AM
Status In Progress [ 3 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Graham Dumpleton made changes - 02/Apr/07 11:23 AM
Status Resolved [ 5 ] Closed [ 6 ]