[cl-who-devel] CL-WHO transformation rule not working?

Edi Weitz edi at agharta.de
Tue Nov 14 19:28:19 UTC 2006


Hi!

On Tue, 14 Nov 2006 18:00:34 +0200, Nico de Jager <ndj at hivsa.com> wrote:

> It seems that the last transformation rule (and example) for
> attribute values described in CL-WHO's documentation is not working.

No, it is working.  See below.

> I am using:
> LispWorks 5.0 for Linux (Debian Sarge)
> CL-WHO-0.6.2
> HUNCHENTOOT-0.4.9
>
> E.g.
> (defun logon-page-html () ;logon-action)
>   (with-html-output (*standard-output*)
>     (:html
>      (:head
>       (:title "test"))
>      (:body
>       "Some text"
>       (:table :border "3"  ; Going to change this!
>        (:tr (:td "1-1") (:td "1-2")))))))
>
> gives the following in 2 browsers:
> Some text
> 1-1  1-2
>
> html:
> <html><head><title>test</title></head><body>Some text<table 
> border='3'><tr><td>1-1</td><td>1-2</td></tr></table></body></html>
>
> While:
> (defun logon-page-html () ;logon-action)
>   (with-html-output (*standard-output*)
>     (:html
>      (:head
>       (:title "test"))
>      (:body
>       "Some text"
>       (:table :border (+ 1 2) ;Substituted (+ 1 2) for "3".
>        (:tr (:td "1-1") (:td "1-2")))))))
>
> only gives the following in the same browsers:
>>1-11-2
> html:
>><tr><td>1-1</td><td>1-2</td></tr></table></body></html>
>
> The output of both cl-who:show-html-expansion and cl-who:with-html-output 
> appear correct in the listener, though:
> CL-USER 11 > (cl-who:show-html-expansion (*standard-output*)
>                (:html
>                 (:head
>                  (:title "test"))
>                 (:body
>                  "Some text"
>                  (:table :border (+ 1 2)
>                   (:tr (:td "1-1") (:td "1-2"))))))
>
> (LET ((*STANDARD-OUTPUT* *STANDARD-OUTPUT*))
>   (PROGN
>     NIL
>     (WRITE-STRING "<html><head><title>test</title></head><body>Some 
> text<table" *STANDARD-OUTPUT*)
>     (LET ((#:G4088 (+ 1 2)))
>       (COND ((NULL #:G4088))
>             ((AND (EQ #:G4088 T) (EQ CL-WHO::*HTML-MODE* :XML)) (PROGN 
> (WRITE-STRING " border='border'" *STANDARD-OUTPUT*)))
>             ((AND (EQ #:G4088 T) (EQ CL-WHO::*HTML-MODE* :SGML)) (PROGN 
> (WRITE-STRING " border" *STANDARD-OUTPUT*)))
>             (T (PROGN (WRITE-STRING " border='" *STANDARD-OUTPUT*) (PRINC 
> #:G4088 *STANDARD-OUTPUT*) (WRITE-STRING "'" *STANDARD-OUTPUT*)))))
>     (WRITE-STRING "><tr><td>1-1</td><td>1-2</td></tr></table></body></html>" 
> *STANDARD-OUTPUT*)))
>
> It seems that only the output of the last "write-string" is sent to
> the browser for the second example.

Your problem is that handlers in Hunchentoot are expected to return a
string and the string your first handler returns is only by pure
coincidence the result you wanted to have.  You're sending the "real"
page to *STANDARD-OUTPUT* where it is not seen by Hunchentoot.

Try to use WITH-HTML-OUTPUT-TO-STRING instead.  That should result in
the same page in both cases.  Take a look at test/test.lisp in
Hunchentoot to see how it's done there.

HTH,
Edi.



More information about the Cl-who-devel mailing list