[hunchentoot-devel] resurrect tbnl's debug-value macro?

Edi Weitz edi at agharta.de
Thu May 3 08:22:52 UTC 2007


On Thu, 3 May 2007 01:14:54 -0700, "Mac Chan" <emailmac at gmail.com> wrote:

> I just noticed today that one of the tbnl's best features is missing
> in hunchentoot.
>
> Previously (in tbnl) if you set *debug-mode* to T, the top level
> dynamic vars *request*, *reply*, etc will be bound to the last
> request, reply objects.
>
> This is very handy and in line with Lisp's interactive development
> model.
>
> I usually setup an empty handler and point the browser to that URL.
>
> Now I can work with the *request* / *reply* objects in the REPL, and
> write html generation and GET/POST handling code interactively.
>
> For instance, I can type these in the REPL
>
>> (setf hunchentoot::*session* (hunchentoot::session-verify *request*))
>
>> (session-value :selected-product)
> "T-Shirt XXL"
>
>> (* (product-price *) (session-value :quantity))
> 15
>
> and so on.
>
> Once I'm satisfied with the result, I put all the code into the handler.
>
> (defun product-total-page (&optional (request *request*))
>   (let ((p (session-value :selected-product))
>         (q (session-value :quantity)))
>    (with-html
>      (:html
>       (:body
>        (:table
>         (:tr (:td "Product") (:td (str p)))
>         (:tr (:td "Quantity") (:td (str q)))
>         (:tr (:td "Total") (:td (str (* q (product-price p)))))))))))
>
> This is also very handy for debugging (inspect *request*'s slots -
> cookies, header and whatnot).
>
> Thoughts?

I removed these variables when porting TBNL because it turned out that
I never used them and I had never heard from anyone else who used
them.  It seems I misjudged... :)

However, can't you have the same result if you add (BREAK) to your
empty handler and set *CATCH-ERRORS-P* to NIL?  I think that
*CATCH-ERRORS-P* is a superior replacement to *DEBUG-MODE* as you
don't have to rely on your clients to not send more than one request.

Cheers,
Edi.



More information about the Tbnl-devel mailing list