Apache Mod-Python - Form of req.filename/req.hlist.directory on Win32 systems.

This is Interesting: Free IT Magazines  
Home > Archive > Apache Mod-Python > April 2006 > Form of req.filename/req.hlist.directory on Win32 systems.





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Form of req.filename/req.hlist.directory on Win32 systems.
Graham Dumpleton

2006-04-18, 12:07 am

I am sure I asked this a long time ago, but have forgotten all the
details.

On Win32 systems does req.filename set by Apache always use POSIX
style forward slashes, ie., '/', to separate components of a
directory? Thus:

/some/path

How does Apache indicate a drive letter when one is necessary? Is it:

c:/some/path

Does any of the above change based on whether forward or backward
slashes are used in a Directory directive? Ie.,

<Directory c:/some/path>
...
</Directory?

vs:

<Directory "c:\\some\\path>
...
</Directory>

Or does Apache not allow the latter anyway?

If Apache does allow the latter, does that mean that req.hlist.directory
is coming through set including backslashes rather than forward
slashes.

I want to get my head around this all again as at different times the
values
of req.filename and req.hlist.directory are used to determine the Python
interpreter name. As highlighted in:

http://issues.apache.org/jira/browse/MODPYTHON-161

If there is a mix of conventions, with user code also being able to
affect
these values, there may be no consistency and thus could end up with
scenarios where a different interpreter to one than was expected will be
used.

Any help from Win32 users in understanding all this would be much
appreciated.

Thanks.

Graham

Nicolas Lehuen

2006-04-18, 12:07 am

Hi Graham,

Here is the test handler I've used :

from mod_python import apache

def handler(req):
req.content_type = 'text/plain'
req.write(req.hlist.directory+'\n')
req.write(req.filename+'\n')
return apache.OK

If I use :

DocumentRoot "c:\\apache22\\htdocs"
<Directory "c:\\apache22\\htdocs">
# ...
SetHandler mod_python
PythonHandler test_handler
</Directory>

I get, when calling http://localhost/index.html:

c:\apache22\htdocs/
C:/apache22/htdocs/index.html

Note that the drive letter has been uppercased and req.filename normalized
to POSIX path names. req.hlist.directory, though supported by Win32, looks
weird.

Now with :

DocumentRoot "c:/apache22/htdocs"
<Directory "c:/apache22/htdocs">
# ...
SetHandler mod_python
PythonHandler test_handler
</Directory>

I get :

c:/apache22/htdocs/
C:/apache22/htdocs/index.html

With :

DocumentRoot "c:/apache22/htdocs"
<Directory "c:\\apache22\\htdocs">
# ...
SetHandler mod_python
PythonHandler test_handler
</Directory>

I get :

c:\apache22\htdocs/
C:/apache22/htdocs/index.html


And finally with :

DocumentRoot "c:\\apache22\\htdocs"
<Directory "c:/apache22/htdocs">
# ...
SetHandler mod_python
PythonHandler test_handler
</Directory>

I get :

c:/apache22/htdocs/
C:/apache22/htdocs/index.html


So req.filename seems always normalized while req.hlist.directory reflects
what was entered in the Directory tag. Both POSIX and Windows forms are
allowed, unfortunately, but the backslash forms needs C-style escaping, and
IIRC the Apache documentation recommends using forward slashes.

Regards,
Nicolas
2006/4/16, Graham Dumpleton <grahamd@dscpl.com.au>:
>
> I am sure I asked this a long time ago, but have forgotten all the
> details.
>
> On Win32 systems does req.filename set by Apache always use POSIX
> style forward slashes, ie., '/', to separate components of a
> directory? Thus:
>
> /some/path
>
> How does Apache indicate a drive letter when one is necessary? Is it:
>
> c:/some/path
>
> Does any of the above change based on whether forward or backward
> slashes are used in a Directory directive? Ie.,
>
> <Directory c:/some/path>
> ...
> </Directory?
>
> vs:
>
> <Directory "c:\\some\\path>
> ...
> </Directory>
>
> Or does Apache not allow the latter anyway?
>
> If Apache does allow the latter, does that mean that req.hlist.directory
> is coming through set including backslashes rather than forward
> slashes.
>
> I want to get my head around this all again as at different times the
> values
> of req.filename and req.hlist.directory are used to determine the Python
> interpreter name. As highlighted in:
>
> http://issues.apache.org/jira/browse/MODPYTHON-161
>
> If there is a mix of conventions, with user code also being able to
> affect
> these values, there may be no consistency and thus could end up with
> scenarios where a different interpreter to one than was expected will be
> used.
>
> Any help from Win32 users in understanding all this would be much
> appreciated.
>
> Thanks.
>
> Graham
>


Graham Dumpleton

2006-04-18, 12:07 am

Was this with mod_python from subversion or 3.2.8?

Want to qualify whether latest set of changes I checked in to support
Files directive has caused it to behave differently as how it determines
req.hlist.directory is different to before.

Thanks.

Graham

On 18/04/2006, at 4:33 AM, Nicolas Lehuen wrote:

> Hi Graham,
>
> Here is the test handler I've used :
>
> from mod_python import apache
>
> def handler(req):
> req.content_type = 'text/plain'
> req.write(req.hlist.directory+'\n')
> req.write(req.filename+'\n' )
> return apache.OK
>
> If I use :
>
> DocumentRoot "c:\\apache22\\htdocs"
> <Directory "c:\\apache22\\htdocs">
> # ...
> SetHandler mod_python
> PythonHandler test_handler
> </Directory>
>
> I get, when calling http://localhost/index.html:
>
> c:\apache22\htdocs/
> C:/apache22/htdocs/index.htmlNote that the drive letter has been
> uppercased and req.filename normalized to POSIX path names.
> req.hlist.directory, though supported by Win32, looks weird.
>
> Now with :
>
> DocumentRoot "c:/apache22/htdocs"
> <Directory "c:/apache22/htdocs">
> # ...
> SetHandler mod_python
> PythonHandler test_handler
> </Directory>
>
> I get :
>
> c:/apache22/htdocs/
> C:/apache22/htdocs/index.html
> With :
>
> DocumentRoot "c:/apache22/htdocs"
> <Directory "c:\\apache22\\htdocs">
> # ...
> SetHandler mod_python
> PythonHandler test_handler
> </Directory>
>
> I get :
>
> c:\apache22\htdocs/
> C:/apache22/htdocs/index.html
> And finally with :
>
> DocumentRoot "c:\\apache22\\htdocs"
> <Directory "c:/apache22/htdocs">
> # ...
> SetHandler mod_python
> PythonHandler test_handler
> </Directory>
>
> I get :
> c:/apache22/htdocs/
> C:/apache22/htdocs/index.html
> So req.filename seems always normalized while req.hlist.directory
> reflects what was entered in the Directory tag. Both POSIX and
> Windows forms are allowed, unfortunately, but the backslash forms
> needs C-style escaping, and IIRC the Apache documentation
> recommends using forward slashes.
>
> Regards,
> Nicolas
> 2006/4/16, Graham Dumpleton <grahamd@dscpl.com.au>: I am sure I
> asked this a long time ago, but have forgotten all the
> details.
>
> On Win32 systems does req.filename set by Apache always use POSIX
> style forward slashes, ie., '/', to separate components of a
> directory? Thus:
>
> /some/path
>
> How does Apache indicate a drive letter when one is necessary? Is it:
>
> c:/some/path
>
> Does any of the above change based on whether forward or backward
> slashes are used in a Directory directive? Ie.,
>
> <Directory c:/some/path>
> ...
> </Directory?
>
> vs:
>
> <Directory "c:\\some\\path>
> ...
> </Directory>
>
> Or does Apache not allow the latter anyway?
>
> If Apache does allow the latter, does that mean that
> req.hlist.directory
> is coming through set including backslashes rather than forward
> slashes.
>
> I want to get my head around this all again as at different times the
> values
> of req.filename and req.hlist.directory are used to determine the
> Python
> interpreter name. As highlighted in:
>
> http://issues.apache.org/jira/browse/MODPYTHON-161
>
> If there is a mix of conventions, with user code also being able to
> affect
> these values, there may be no consistency and thus could end up with
> scenarios where a different interpreter to one than was expected
> will be
> used.
>
> Any help from Win32 users in understanding all this would be much
> appreciated.
>
> Thanks.
>
> Graham
>



Nicolas Lehuen

2006-04-18, 12:07 am

This was with the Subversion trunk.

I"ll do some tests with 3.2.8 and tell you the results.

Nicolas

2006/4/17, Graham Dumpleton <grahamd@dscpl.com.au>:
>
> Was this with mod_python from subversion or 3.2.8?
>
> Want to qualify whether latest set of changes I checked in to support
> Files directive has caused it to behave differently as how it determines
> req.hlist.directory is different to before.
>
> Thanks.
>
> Graham
>
> On 18/04/2006, at 4:33 AM, Nicolas Lehuen wrote:
>
>
>


Nicolas Lehuen

2006-04-20, 7:02 pm

Hi Graham,

It looks like with mod_python 3.2.8, both req.filename and
req.hlist.directory are normalized, so your latest changes may introduce a
regression for those who expect req.hlist.directory to be normalized.

Regards,
Nicolas

2006/4/18, Nicolas Lehuen <nicolas@lehuen.com>:
>
> This was with the Subversion trunk.
>
> I"ll do some tests with 3.2.8 and tell you the results.
>
> Nicolas
>
> 2006/4/17, Graham Dumpleton < grahamd@dscpl.com.au>:
>
>


Graham Dumpleton

2006-04-20, 7:02 pm

Can you check out latest code from subversion trunk and try test again?

Think I have worked out the required magic this time. If have, this
is good
as this will help me solve some of the problems mentioned in:

http://issues.apache.org/jira/browse/MODPYTHON-161

as well.

Thanks.

Graham

On 19/04/2006, at 12:02 AM, Nicolas Lehuen wrote:

> Hi Graham,
>
> It looks like with mod_python 3.2.8, both req.filename and
> req.hlist.directory are normalized, so your latest changes may
> introduce a regression for those who expect req.hlist.directory to
> be normalized.
>
> Regards,
> Nicolas
>
> 2006/4/18, Nicolas Lehuen <nicolas@lehuen.com>:
> This was with the Subversion trunk.
>
> I"ll do some tests with 3.2.8 and tell you the results.
>
> Nicolas
>
> 2006/4/17, Graham Dumpleton < grahamd@dscpl.com.au>:
> Was this with mod_python from subversion or 3.2.8?
>
> Want to qualify whether latest set of changes I checked in to support
> Files directive has caused it to behave differently as how it
> determines
> req.hlist.directory is different to before.
>
> Thanks.
>
> Graham
>
> On 18/04/2006, at 4:33 AM, Nicolas Lehuen wrote:
>
> it:
> the
>
>
>



Nicolas Lehuen

2006-04-20, 7:02 pm

Hi Graham,

OK, it works as in 3.2.8 now, i.e. req.hlist.directory is always normalized..

There is something strange, though, and I cannot verify right now whether it
was the same behaviour in 3.2.8. If I request a non-existent page, for
example http://localhost/foobar/doesntexists.html, req.filename is
C:/apache22/htdocs/foobar, without doesntexists.html. I can understand that
req.filename may be invalid if the requested file doesn't exists, but why do
I get the non-existent foobar directory if I don't get doesntexists.html ?

Regards,
Nicolas

2006/4/19, Graham Dumpleton <grahamd@dscpl.com.au>:
>
> Can you check out latest code from subversion trunk and try test again?
>
> Think I have worked out the required magic this time. If have, this
> is good
> as this will help me solve some of the problems mentioned in:
>
> http://issues.apache.org/jira/browse/MODPYTHON-161
>
> as well.
>
> Thanks.
>
> Graham
>
> On 19/04/2006, at 12:02 AM, Nicolas Lehuen wrote:
>
>
>


Graham Dumpleton

2006-04-20, 7:02 pm

If I remember correctly, that is part of Apache's weird matching rules.
It was ages ago when I tried to work out how it works for missing files.
I should revisit it and document it at least for myself.

Anyway, I certainly don't modify req.filename, so shouldn't be the=20
changes
I made.

Graham

On 20/04/2006, at 7:31 AM, Nicolas Lehuen wrote:

> Hi Graham,
>
> OK, it works as in 3.2.8 now, i.e. req.hlist.directory is always=20
> normalized.
>
> There is something strange, though, and I cannot verify right now=20
> whether it was the same behaviour in 3.2.8. If I request a=20
> non-existent page, for example=20
> http://localhost/foobar/doesntexists.html, req.filename is=20
> C:/apache22/htdocs/foobar, without doesntexists.html. I can understand=20=


> that req.filename may be invalid if the requested file doesn't exists,=20=

[vbcol=seagreen]
> but why do I get the non-existent foobar directory if I don't get=20
> doesntexists.html ?
>
> Regards,
> Nicolas
>
> 2006/4/19, Graham Dumpleton <grahamd@dscpl.com.au>:
[vbcol=seagreen]
[vbcol=seagreen]


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com