[Lispweb] POST variables in araneida

Richard Newman r.newman at reading.ac.uk
Fri Mar 3 23:05:55 CST 2006


James,
   You might be interested in something like

   (flet
     ((write-body-bindings (binding-specifiers body)
        "Auxiliary function for with-request-params."
        (loop for (var param &optional type-fun) in binding-specifiers
              collecting
              (list var
                    (if type-fun
                      (list type-fun (list 'body-param param body))
                      (list 'body-param param body))))))

     (defmacro with-body-params (request binding-specifiers &body body)
       "Each binding specifier is a triple, (var param &optional type- 
fun).
        If TYPE-FUN is not provided, CAR is used to get rid of the  
wrapping
        list that URL-QUERY-PARAM returns."
       (let ((r-body (gensym)))
         `(let ((,r-body (request-body ,request)))
            (let (,@(write-body-bindings binding-specifiers r-body))
              , at body)))))

   which will save you typing out a load of calls to BODY-PARAM, if  
you're using form-encoded bodies.

   I'm sure Alan has something a lot more integrated!

   Take a look in (IIRC) daemon.lisp to see how bodies are handled.  
We had some discussion of this many moons ago.

-R

On 3 Mar 2006, at 20:00, James Fleming wrote:

>> Stupid question time: when using POST to submit a form, how do I
>> retrieve the data sent by the browser?
>
> Embarrassing answer time: the clue I needed was on the Cliki page.
> (request-body request) gives me what I need.
>
> In penance, I shall write a HOWTO for araneida, once I've gotten the
> whole thing running.
>
>
> Cheers,
> James
> -- 
> Stupidity killed the cat.
> Curiosity was framed.
> _______________________________________________
> lispweb mailing list
> lispweb at red-bean.com
> http://www.red-bean.com/mailman/listinfo/lispweb




More information about the lispweb mailing list