Resolved: (MODPYTHON-22) mod_python.publisher extension handling
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 > Resolved: (MODPYTHON-22) mod_python.publisher extension handling




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

    Resolved: (MODPYTHON-22) mod_python.publisher extension handling  
Nicolas Lehuen (JIRA)


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


 
04-30-05 07:45 AM

[ http://issues.apache.org/jira/brows...HON-22?page=all ]

Nicolas Lehuen resolved MODPYTHON-22:
-------------------------------------

Assign To: Nicolas Lehuen
Resolution: Fixed
Fix Version: 3.2.0

Resolved along with MODPYTHON-9.

> mod_python.publisher extension handling
> ---------------------------------------
>
>          Key: MODPYTHON-22
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-22
>      Project: mod_python
>         Type: Bug
>     Versions: 3.1.4, 3.1.3
>     Reporter: Graham Dumpleton
>     Assignee: Nicolas Lehuen
>     Priority: Minor
>      Fix For: 3.2.0

>
> The following code in mod_python.publisher doesn't appear to be correct.
>   imp_suffixes = " ".join([x[0][1:] for x in imp.get_suffixes(
)])
>     # get rid of the suffix
>     #   explanation: Suffixes that will get stripped off
>     #   are those that were specified as an argument to the
>     #   AddHandler directive. Everything else will be considered
>     #   a package.module rather than module.suffix
>     exts = req.get_addhandler_exts()
>     if not exts:
>         # this is SetHandler, make an exception for Python suffixes
>         exts = imp_suffixes
>     if req.extension:  # this exists if we're running in a | .ext handler
>         exts += req.extension[1:]
>     if exts:
>         suffixes = exts.strip().split()
>         exp = "\\." + "$|\\.".join(suffixes)
>         suff_matcher = re.compile(exp) # Python caches these, so its fast
>         module_name = suff_matcher.sub("", module_name)
> For starters, imp.get_suffixes() returns:
>     [('.so', 'rb', 3), ('module.so', 'rb', 3), ('.py', 'U', 1), ('.pyc
', 'rb', 2)]
> on a UNIX platform. Thus yielding for imp_suffixes:
>   'so odule.so py pyc'
> Ie., "m" has been lost from "module.so". As it is likely that a dynamicall
y
> loaded C module isn't going to be usable within publisher, this is no loss
> at this point.
> Now if one were using:
>   SetHandler python-program
>   PythonHandler mod_python.publisher | .xxx
>   PythonHandler mod_python.publisher | .py
> then req.get_addhandler_exts() returns:
>   ''
> Ie., empty string. Thus, "exts" gets set to imp_suffixes.
>   exts = 'so odule.so py pyc'
> Now because ".py" and ".xxx" was specified on the PythonHandler line, req.
extension
> is set to be ".py" or ".xxx" as appropriate for request. When this is appe
nded to "exts",
> no space is added and thus result for ".py" request is:
>   exts = 'so odule.so py pycpy'
> For a ".py" extension this is no drama as it is already listed in exts at 
that
> point and thus things still work okay.
> The lack of a space though does screw things for ".xxx" though. If one use
d a URL
> with a .xxx extension, one would expect it to drop the extension and still
 work,
> but because exts gets rewritten as:
>   exts = 'so odule.so py pycxxx'
> it doesn't work, instead you get not found error.
> The only way around it is to use:
>   SetHandler python-program
>   AddHandler python-program .xxx
>   PythonHandler mod_python.publisher | .xxx
>   PythonHandler mod_python.publisher | .py
> Ie., as well as SetHandler, define AddHandler for at least one extension t
ype.
> In doing this, req.get_addhandler_exts() now returns:
>   'xxx '
> Notice how there is a space at the end of the string. That it is set means
 exts
> isn't set to imp_suffixes. When req.extension is added the existing space 
means
> all is okay and result will be:
>   'xxx xxx'
> In summary, instead of:
>   exts += req.extension[1:]
> should be equivalent of:
>   exts += ' '
>   exts += req.extension[1:]
> Do note that in case of req.get_addhandler_exts() returning something, thi
s
> will mean spaces are doubled up. This appears to be okay as split() functi
on
> treats adjoining spaces as a single field separator when splitting string.
> Another bit of code which is a bit loose is:
>   exp = "\\." + "$|\\.".join(suffixes)
> When this is applied to:
>    'xxx xxx'
> one gets:
>   '\\.xxx$|\\.xxx'
> The intent of the regular expression when applied is that it will remove t
he
> extension just from the end of the URL. Ie., "foo.xxx" yields "foo". Howev
er,
> because there is no '$' on the very last part of the pattern, any instance
 of
> the last extension will be removed from anywhere in the string. ie.:
>   suff_matcher.sub("","aaa.xxxbbb.foo.xxx")
> yields:
>   'aaabbb.foo'
> instead of:
>   "aaa.xxxbbb.foo"
> At the moment this may not be an issue as the way Apache does its matching
> and Python does its module lookup, means that neither would produce a vali
d
> result in the first place even if one were to have files with '.' in the a
ctual name
> besides that used for the extension. :-)
> The missing space still needs to be fixed though.






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 05:53 AM.      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