[tbnl-devel] PATH_INFO
Bob Hutchison
hutch at recursive.ca
Fri Oct 7 12:09:54 UTC 2005
Hi,
Sorry I'm in a rush out the door, shouldn't really be writing this
now...
Is this what you had in mind Peter...
I agree with Edi about not making sense in the general case, but that
there is a really really common case, and that's where you are using
a prefix to dispatch (maybe Java's influence, maybe just because it
makes for useful URLs?) anyway...
I've take two approaches to how this works, currently using TBNL,
I've been writing things like:
(let ((command (cdddr (split-sequence:split-sequence #\/ (script-
name)))))...
in the handler.
This is a bit ugly because you have to count the 'd's in your cd*r --
but I note that the dispatch prefix is not always the same as the
command prefix (dispatch prefixes can take a minimalist approach,
only specify the minimum needed) so the handler had to do some work
or know something anyway.
(btw, I used the word 'command', Peter used 'PATH_INFO' -- I don't
really like either :-)
Anyway, if you do this then you have a list of strings. Handy.
In a much larger Java application this was far too limiting. I wrote
a dispatching system that allowed the programmer to name parts of the
URL in the regex used to dispatch. The named parts were then turned
into parameter like things. Sooner or later I'm going to have to
write this in lisp.
Cheers,
Bob
On Oct 7, 2005, at 5:19 AM, Edi Weitz wrote:
> On Fri, 7 Oct 2005 11:04:26 +0200, Peter BARABAS
> <peter.barabas at gmail.com> wrote:
>
>
>
>> I don't know if it makes sense, but I'd treat the prefix dispatch
>> part as SCRIPT_NAME and everything after it as PATH_INFO. E.g. in
>> http://www.something.net/authors/Kurt_Vonnegut "/authors/" would be
>> the SCRIPT_NAME and "Kurt_Vonnegut" the PATH_INFO. Again, this might
>> be non-sense.
>>
>>
>
> Yes, that would make sense with prefix dispatchers but not with
> arbitrary dispatchers. What if the dispatcher dispatches depending on
> the last three characters of the URI? Or depending on the phase of
> the moon?
>
> I think what you want can be achieved if you, in your own dispatcher,
> set AUX-REQUEST-VALUE to whatever information about the URI you want
> to communicate to the handlers. Only the dispatcher can know which
> part of the URI is relevant to the handler and which isn't.
>
> On a related note, I agree that SCRIPT-NAME might not be the best name
> but at the moment it's at least well-defined.
>
> Cheers,
> Edi.
> _______________________________________________
> tbnl-devel site list
> tbnl-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/tbnl-devel
>
>
----
Bob Hutchison -- blogs at <http://www.recursive.ca/hutch/>
Recursive Design Inc. -- <http://www.recursive.ca/>
Raconteur -- <http://www.raconteur.info/>
More information about the Tbnl-devel
mailing list