Commented: (MODPYTHON-126) PythonHandler in <Files>
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache Mod-Python > Commented: (MODPYTHON-126) PythonHandler in <Files>




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Commented: (MODPYTHON-126) PythonHandler in <Files>  
Graham Dumpleton (JIRA)


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-14-06 12:46 PM

[ http://issues.apache.org/jira/brows...236
6319 ]

Graham Dumpleton commented on MODPYTHON-126:
--------------------------------------------

FWIW, I think I know how to fix the above so it works. This time I stumbled 
onto the fact that in Apache one can programmatically query back through the
 contexts of directives defined in a configuration. This will allow the code
 which deals with Python*Ha
ndler directives to query back looking for the Directory or DirectoryMatch d
irective it was used in.

If it can't find either, then it would have been a Location directive and it
 now will know the URL should not be used as the handler directory. If it di
d find Directory, it could work out the argument to it and use that as the b
asis for working out the di
rectory. Ie., it would skip past any File directives and go direct to the Di
rectory context.

The only trick to solve is the best way of dealing with wildcards or regexes
 for directory. One probably has to leave it until the very point that reque
st is being handled, which means that Apache wildcard/regex matching routine
s may need to be exposed in
mod_python Python APIs to ensure same matching scheme can be used against th
e req.filename member.

Thus, my whole idea of being able to mark base directories as discussed on m
ailing list is no longer relevant to solving this particular issue.


> PythonHandler in <Files> directive sets req.hlist.directory to useless val
ue.
> --------------------------------------------------------------------------
---
>
>          Key: MODPYTHON-126
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-126
>      Project: mod_python
>         Type: Bug
>   Components: core
>     Versions: 3.2
>     Reporter: Graham Dumpleton

>
> When you have Apache ".htaccess" configuration like:
>   SetHandler mod_python
>   #PythonPath "['/Users/grahamd/Sites/auth']+sys.path"
>   <Files "page1.txt">
>   PythonHandler page1::handler_txt
>   </Files>
>   <Files "page2.txt">
>   PythonHandler page2::handler_txt
>   </Files>
> and "page1.txt" is accessed, the req.hlist.directory attribute, which is s
upposed to list the name of the directory the PythonHandler directive was us
ed in, gets set to "page1.txt/" instead.
> This value then gets added into "sys.path". Because it doesn't actually id
entify the directory, the module "page1" cannot actually be found when the i
mport is performed.
> [Fri Feb 10 09:08:40 2006] [error] [client 127.0.0.1] PythonHa
ndler page1::handler_txt: Traceback (most recent call last):
> [Fri Feb 10 09:08:40 2006] [error] [client 127.0.0.1] PythonHa
ndler page1::handler_txt:   File "/System/Library/Frameworks/Python.framewor
k/Versions/2.3/lib/python2.3/site-packages/mod_python/apache.py", line 288, 
in HandlerDispatch\n    log=debug)
> [Fri Feb 10 09:08:40 2006] [error] [client 127.0.0.1] PythonHandler pa
ge1::handler_txt:   File "/System/Library/Frameworks/Python.framework/Versions/2.3/l
ib/python2.3/site-packages/mod_python/apache.py", line 508, in import_module\n    f,
 p, d = imp.fin
d_module(parts[i], path)
> [Fri Feb 10 09:08:40 2006] [error] [client 127.0.0.1] PythonHa
ndler page1::handler_txt: ImportError: No module named page1
> The only workaround at this point is to explicitly define the PythonPath directive
 to include the directory the modules and ".htaccess" file are in. Not sure yet whet
her there is a way in Apache of determining the directory the "Files" directive is u
sed
in and set "req.hlist.directory" correctly.






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:52 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register