From: Stefan Nobis
Subject: [TBNL] No access to variables
Date: 
Message-ID: <87u0kj48pr.fsf@snobis.de>
Hi.

My first steps with TBNL and CL-WHO. I tried to write a simple
default-handler which just outputs some global variables i want to
use. But they seem to evaluate to nil. Here's my code:

----------------------------------------------------------------------
(in-package :my-tbnl-site)

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter *basedir*
    (merge-pathnames
     (make-pathname :directory (pathname-directory *load-truename*))
     (user-homedir-pathname)))

  (defparameter *config-file*
    (merge-pathnames
     (make-pathname :name (pathname-name *load-truename*)
                    :type "db")
     *basedir*)))

(defun foo ()
  (log-message :info "My handler called for script ~A (cfg: ~A)" (script-name) *config-file*)
  (with-html-output-to-string (*standard-output* nil :prologue t)
    (:html
     (:head (:title "First steps"))
     (:body
      (:h1 "title")
      (:p "config: " (namestring *config-file*))
      (:p "loadname: " *load-truename*)
      (:p "script: " (script-name))))))

(setq *default-handler* 'foo)
----------------------------------------------------------------------

The log-message works, script-name and *config-file* are correctly
written. But in with-html-output-to-string everythings seems to
evaluate to nil (only the literal text shows up). What am i doing
wrong?

-- 
Stefan.
From: Edi Weitz
Subject: Re: [TBNL] No access to variables
Date: 
Message-ID: <uekbnyqxd.fsf@agharta.de>
On Tue, 31 May 2005 19:16:16 +0200, Stefan Nobis <······@gmx.de> wrote:

> (defun foo ()
>   (log-message :info "My handler called for script ~A (cfg: ~A)" (script-name) *config-file*)
>   (with-html-output-to-string (*standard-output* nil :prologue t)
>     (:html
>      (:head (:title "First steps"))
>      (:body
>       (:h1 "title")
>       (:p "config: " (namestring *config-file*))
>       (:p "loadname: " *load-truename*)
>       (:p "script: " (script-name))))))
>
> (setq *default-handler* 'foo)
>
> The log-message works, script-name and *config-file* are correctly
> written. But in with-html-output-to-string everythings seems to
> evaluate to nil (only the literal text shows up). What am i doing
> wrong?

[Please send questions like these to the corresponding mailing list.
Thanks.]

Use STR or ESC or FMT - see

  <http://weitz.de/cl-who/#esc>

and

  <http://weitz.de/cl-who/#syntax>.

Example (untested):

  (defun foo ()
    (log-message :info "My handler called for script ~A (cfg: ~A)" (script-name) *config-file*)
    (with-html-output-to-string (*standard-output* nil :prologue t)
      (:html
       (:head (:title "First steps"))
       (:body
        (:h1 "title")
        (:p "config: " (str (namestring *config-file*)))
        (:p "loadname: " (fmt "~A" *load-truename*))
        (:p "script: " (esc (script-name)))))))

Cheers,
Edi.

-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq ·········@agharta.de" 5) "edi")