durusmail: quixote-users: puzzled by trailing / in URL
puzzled by trailing / in URL
puzzled by trailing / in URL
Greg Ward
On 12 October 2001, Ray Drew said:
> running quixote 0.41 on win nt4, apache 1.3, mod_python
> I'm new to web programming, so apologies if this is a stupid question.

It's not stupid at all.  What to do about trailing slashes in URLs is
one of the trickier subtleties to web programming.  One thing to ponder:
there is no such thing as a trailing slash; there are only URLs with an
empty final component.

> Some effort is made so that both /qdemo/ and /qdemo work as a URL.

Correct -- both in Quixote itself and in the  directive
recommended by doc/web-server.txt.

Speaking of which, what does everyone think of changing that directive

Is that any clearer or cleaner?  (I'm pretty sure it's equivalent, but
if I'm wrong please tell me!)

> /qdemo/simple works /qdemo/simple/ doesn't (is it because there are no
> further options after simple?)

Do you have SECURE_ERRORS = 0 in demo.conf?  If so, you should get a
somewhat useful error message when you access /qdemo/simple/.  Here's
what it tells me:

  The requested link "/q/simple/" was not found:
   has no _q_exports list

The Pythonic answer: 'simple()' is a function, not a namespace.  Asking
Quixote for "/q/simple" is like asking Python for 'quixote.demo.simple';
Quixote then decides that you really wanted to call that function.
Asking Quixote for "/q/simple/" is quite different: it's like asking
Python for 'quixote.demo.simple._q_index' (Quixote dictates that a URL
with an empty final component means you really want the index object,
'_q_index'; again it takes the initiative to call this object for you.)

To put it in traditional URL-space-as-filesystem terms: "/q/simple" is a
file, not a directory (folder).  By asking for "/q/simple/", you're
asking for the index file in directory "/q/simple" -- again, the empty
final component means you implicitly want the index object.  /q/simple
is a "file", not a "directory", so it doesn't have an index.

> /qdemo/12/ works but /qdemo/12 doesn't. (there are further options after 12,
> so to be consistent, shouldn't /qdemo/12 work like /qdemo does?)

That's odd -- it works for me, either with CGI or FastCGI.  In
particular, /q/12 issues a redirect to /q/12/.  Your assumption that
/q/12 should work just like /q is correct, and in fact it does work that
way.  Or it least it's supposed to.

How does it work when you run the demo as a CGI script?  Again, this
might be a mod_python thing, or a mod_python-under-NT thing.

Greg Ward - software developer                gward@mems-exchange.org
MEMS Exchange                            http://www.mems-exchange.org