Macro: defwethod

Documentation

Defines a wethod that allows the special forms `read-form' and `render' in the body.

Source

(defmacro defwethod (name fn-list &body body)
  "Defines a wethod that allows the special forms `read-form' and `render' in the body."
  ;; TODO combine this with defwethod
  ;; add session id later.
  `(progn
     (defmethod ,name ,fn-list
       ;; The web-server doesn't know the package of this wethod. 
       (let ((*package* (find-package ,(package-name *package*))))
	 (with-call/cc 
	   (block ,name	;; block names outside with-call/cc are not visible inside.
	     (macrolet
		 ((read-form (&rest args) `(%read-form-macro ,',name ,@args))
		  (render (&rest args)
		    `(respond-with-html (*html-out*)
		       (with-foo-output (*html-out*)
			 ,(if (null args)
			      '(render-view ',name ,@(mapcar (fn (arg-spec)
							       (if (consp arg-spec)
								   (car arg-spec)
								   arg-spec))
							     fn-list))
			      `(render-view ,',name ,@args))))))
	       ,@body)))))
     (save-wethod ',name)
     ',name))
Source Context