Commented: (MODPYTHON-161) Wrong interpreter chosen with
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-161) Wrong interpreter chosen with




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

    Commented: (MODPYTHON-161) Wrong interpreter chosen with  
Graham Dumpleton (JIRA)


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


 
05-07-06 12:11 PM

[ http://issues.apache.org/jira/brows...237
8273 ]

Graham Dumpleton commented on MODPYTHON-161:
--------------------------------------------

The directory supplied to req.register_input_filter() and req.register_outpu
t_filter() also needs to be canonicalised (made POSIX style) and trailing sl
ash added to fix issues with PythonInterpPerDirective.

The issues with Win32 backward slash versus forward slash are a non issue fo
r directory derived from directive specified in configuration as that was to
 do with incomplete changes related to MODPYTHON-126, which has since been a
ddressed.



> Wrong interpreter chosen with req.add_handler()/PythonInterpPerDirective.
> -------------------------------------------------------------------------
>
>          Key: MODPYTHON-161
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-161
>      Project: mod_python
>         Type: Bug

>   Components: core
>     Versions: 3.3
>     Reporter: Graham Dumpleton
>     Assignee: Graham Dumpleton

>
> Having fixed MODPYTHON-160, if using:
> # .htaccess
> SetHandler mod_python
> PythonInterpPerDirective On
> PythonFixupHandler interpreter_1
> # interpreter_1.py
> from mod_python import apache
> import os, sys
> directory = os.path.dirname(__file__)
> def fixuphandler(req):
>     req.log_error("fixuphandler")
>     req.log_error("interpreter=%s"%req.interpreter)
>     req.log_error("directory=%s"%req.hlist.directory)
>     req.add_handler("PythonHandler","interpreter_1",directory)
>     return apache.OK
> def handler(req):
>     req.log_error("handler")
>     req.log_error("interpreter=%s"%req.interpreter)
>     req.log_error("directory=%s"%req.hlist.directory)
>     req.content_type = 'text/plain'
>     req.write('hello')
>     return apache.OK
> when select_interp_name() in src/mod_python.c tries to determine the interpreter n
ame, for PythonInterPerDirective, it will use the value as supplied as directory arg
ument to req.add_handler(). In doing this though, it doesn't consider the fact that 
the
directory may not have a trailing slash and since interpreter names for PythonInterpPerDirec
tive always have a trailing slash, the handler will not be executed in correct interpreter c
ontext.
> [Sun Apr 16 17:20:00 2006] [notice] mod_python: (Re)importing modu
le 'interpreter_1'
> [Sun Apr 16 17:20:00 2006] [error] [client ::1] fixuphandler
> [Sun Apr 16 17:20:00 2006] [error] [client ::1] interpreter=/U
sers/grahamd/Workspaces/testing/interpreter-1/
> [Sun Apr 16 17:20:00 2006] [error] [client ::1] directory=/Use
rs/grahamd/Workspaces/testing/interpreter-1/
> [Sun Apr 16 17:20:00 2006] [notice] mod_python: (Re)importing modu
le 'interpreter_1'
> [Sun Apr 16 17:20:00 2006] [error] [client ::1] handler
> [Sun Apr 16 17:20:00 2006] [error] [client ::1] interpreter=/U
sers/grahamd/Workspaces/testing/interpreter-1
> [Sun Apr 16 17:20:00 2006] [error] [client ::1] directory=/Use
rs/grahamd/Workspaces/testing/interpreter-1
> A further problem is that normally the path indicating where a directive was defin
ed is internally calculated from Apache configuration and thus always uses POSIX dir
ectory conventions, ie., forward slash. If the above code were run on Win32, the dir
ect
ory calculated from __file__ is going to most likely use DOS directory conve
ntions, ie., backward slash. Thus, even if a trailing slash were to be added
, it still will not work because the remainder of the path is going to use b
ackward slash and thus the
interpreter name still will not match what it probably should be.
> The main purpose of the directory argument to req.add_handler() is to know where t
o find the module referenced in the handler argument. In this case it is also used t
o determine the Python interpreter name. The fix may be that the interpreter name be
 de
termined in some other way based on the interpreter in use when the req.add_handler() call w
as made.
> This is just part of problems I can possibly see with calculation of interpreter n
ames for handlers. More on this another time. :-)






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 10:07 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