Hi,
I really like the way DEFINE-EASY-HANDLER works with supplied form field parameters. But the problem with it is, IMHO, that you cannot use DEFINE-EASY-HANDLER everywhere in the code when you want to reach to a form variable. Therefore I come up with such a solution:
(let ((default-parameter-type ''string) (default-request-type :both)) (defmacro with-form-fields ((&rest fields) &body body) `(let ,(loop for field in fields collect (hunchentoot::make-defun-parameter field default-parameter-type default-request-type)) ,@body)))
I couldn't be sure if using an unexported function is the right way to go here, therefore I'm here for your help. Is there any other function provided by hunchentoot to have the same effect as WITH-FORM-FIELDS? If there isn't any, maybe others too would be happy to see this function coming default with hunchentoot.
Regards.
Hi,
On Sun, 22 Apr 2007 21:15:09 +0300, Volkan YAZICI yazicivo@ttnet.net.tr wrote:
I really like the way DEFINE-EASY-HANDLER works with supplied form field parameters. But the problem with it is, IMHO, that you cannot use DEFINE-EASY-HANDLER everywhere in the code when you want to reach to a form variable. Therefore I come up with such a solution:
(let ((default-parameter-type ''string) (default-request-type :both)) (defmacro with-form-fields ((&rest fields) &body body) `(let ,(loop for field in fields collect (hunchentoot::make-defun-parameter field default-parameter-type default-request-type)) ,@body)))
I couldn't be sure if using an unexported function is the right way to go here, therefore I'm here for your help. Is there any other function provided by hunchentoot to have the same effect as WITH-FORM-FIELDS?
No, not really. You could of course cook up something yourself but it'd be kind of re-inventing the wheel.
If there isn't any, maybe others too would be happy to see this function coming default with hunchentoot.
Yes, I think that makes sense. I'll add something like this to the next release.
Thanks, Edi.
Hi--
I had something like:
(defmacro with-parameters (parameters &body body) `(let ,(mapcar (lambda (p) `(,p (hunchentoot:parameter ,(string-downcase (symbol-name p))))) parameters) ,@body))
(macroexpand-1 '(with-parameters (id title description) (format t "Id is ~A, title ~A, desc, ~A" id title description))) (LET ((ID (HUNCHENTOOT:PARAMETER "id")) (TITLE (HUNCHENTOOT:PARAMETER "title")) (DESCRIPTION (HUNCHENTOOT:PARAMETER "description"))) (FORMAT T "Id is ~A, title ~A, desc, ~A" ID TITLE DESCRIPTION))
regards
T
Edi Weitz edi@agharta.de writes:
If there isn't any, maybe others too would be happy to see this function coming default with hunchentoot.
Yes, I think that makes sense. I'll add something like this to the next release.
Also, it will be really useful if we would be able to specify default values for parameter-type and request-type inside WITH-FORM-FIELDS.
Regards.
Scribit Volkan YAZICI dies 27/04/2007 hora 02:22:
Also, it will be really useful if we would be able to specify default values for parameter-type and request-type inside WITH-FORM-FIELDS.
I really think with-parameters is a better name than with-form-fields because what you access really are parameters, and nothing says they come from form fields.
Taxonomically, Pierre