James Gardner wrote:
Hi Jose,
I've tried your suggestion of using:
self.directory = os.path.normpath(directory)
and that works fine too so I'll check that in instead if you'd prefer?
I think that makes sense.
James Gardner wrote:
>> At the moment if I put in a URL which resolves to a directory this
>> code kicks in (line 460 of paste.urlparser):
>>
>> if os.path.isdir(full):
>> # @@: Cache?
>> child_root = self.root_directory is not None and \
>> self.root_directory or self.directory
>> return self.__class__(full, root_directory=child_root,
>> cache_max_age=self.cache_max_age)(environ,
>> start_response)
Ian Bicking wrote:
> Huh... it's supposed to do the recursive traversal of directories. So
> it just creates another instance of StaticURLParser that points to the
> subdirectory, and then passes the request off to that.
I don't understand why you'd ever want to do this? It only ever gets
called if the URL maps to a directory and if that is the case it should
return a 403. I'll change it.
This is how subdirectories are handled:
SCRIPT_NAME=''; PATH_INFO='/foo/bar/baz.html'
maps to app StaticURLParser('/www')
That in turn forwards the request as:
SCRIPT_NAME='/foo'; PATH_INFO='/bar/baz.html'
maps to app StaticURLParser('/www/foo')
And so forth, until you get to a real file.
But if you end up at a directory instead of a file, it isn't working.
> It doesn't seem to have reasonable behavior when a StaticURLParser
> instance is asked to serve itself, not a subfile. Probably it should
> return 403 Forbidden in that case
Should it do this rather than 404? I only ask because it is used in the
config/middleware.py Cascade and if a 403 is returned, other parts of
the app won't get called but if this is the correct behavior that's fine.
404 would be okay, I guess, though the actual error message should say
something different so people realize why they get a 404. Apache gives
a 403, though IMHO that's probably a bad convention. It's only
Forbidden in Apache because indexes weren't turned on, but calling
enabling indexes a permission (that can be revoked) doesn't make any
sense. So sure, 404 with a message "No index file displayed for
directories" or something like that. Alternately we could display
index.html (probably based on a class method, or something passed to the
constructor, which would be a list of index filenames -- but I'm also
fine leaving it out so long as the 404 is sent in a special method that
can be overridden).
--
Ian Bicking | [EMAIL PROTECTED] | http://blog.ianbicking.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---