Re: [Chicken-users] url-encoded arguments et similia
On 5/26/05, Michele Simionato [EMAIL PROTECTED] wrote: After yesterday praise, let's come back to the usual posts of problems issues ;) It seems I cannot get argument, current-urlencoded-arguments, post-var and get-var working. Here is an example of the issue: (define-http-resource (/get-a-b a b) `(div (form (@ (method get)) (input (@ (type text) (name a))) (br) (input (@ (type text) (name b))) (br) (input (@ (type submit) (name ok ,(format a = ~s b = ~s args = ~a a b (current-urlencoded-arguments (current-urlencoded-arguments) gives the empty string all the time, no matter what is in the query string. For instance if I point my browser to http://localhost:4242/get-a-b?a=1b=2ok I get a = 1 b = 2 args = () What am I missing? That parameter is only bound in the fallback-handler, that is, for special requests like .ssp pages. Here's a patch for spiffy.scm: cd /home/fwinkel/tmp/ diff -c /home/fwinkel/tmp/spiffy.scm\~ /home/fwinkel/tmp/spiffy.scm --- /home/fwinkel/tmp/spiffy.scm~ 2005-03-02 23:07:13.0 +0100 +++ /home/fwinkel/tmp/spiffy.scm2005-05-26 08:48:40.131738408 +0200 @@ -48,14 +48,15 @@ `(http:add-resource ,url (lambda (,req ,args) - (call/cc -(lambda (,ret) - (let ([respond (http-resource:responder ,req ,ret)]) -(handle-exceptions exn -(parameterize ([http:error-response-handler (http-resource:error-handler exn)]) - (http:write-error-response 500 Internal Server Error) ) - (respond - (let ,(map (lambda (arg) -`(,(string-symbol (car arg)) (alist-ref ,(car arg) ,args string-ci=? ,(cdr arg))) ) - rargs) - ,@body) ) ) ) ) ) ) ) ) ) + (parameterize ((current-urlencoded-arguments ,args)) + (call/cc + (lambda (,ret) +(let ([respond (http-resource:responder ,req ,ret)]) + (handle-exceptions exn + (parameterize ([http:error-response-handler (http-resource:error-handler exn)]) +(http:write-error-response 500 Internal Server Error) ) +(respond + (let ,(map (lambda (arg) + `(,(string-symbol (car arg)) (alist-ref ,(car arg) ,args string-ci=? ,(cdr arg))) ) +rargs) + ,@body) ) ) ) ) ) ) ) ) ) ) cheers, felix ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] url-encoded arguments et similia
On 5/26/05, felix winkelmann [EMAIL PROTECTED] wrote: That parameter is only bound in the fallback-handler, that is, for special requests like .ssp pages. Here's a patch for spiffy.scm: snip Cool! Please make it (parameterize ((current-urlencoded-arguments ,args) (current-request ,req)) so that post-var works too. Actually I like a lot this function, which I have extracted from define-http-resource: (define (add-dynamic-resource url thunk) (http:add-resource url (lambda (request args) (parameterize ((current-urlencoded-arguments args) (current-request request)) (let/cc return (let/ respond (http-resource:responder request return) (handle-exceptions exn (parameterize ([http:error-response-handler (http-resource:error-handler exn)]) (http:write-error-response 500 Internal Server Error)) (respond (thunk) Maybe it would be a good idea to expose it directly, would do you think? Michele Simionato ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] an ode to Spiffy
Magnus Therning [EMAIL PROTECTED] writes: I'm sure you've read what Paul Graham has to say after using Lisp (almost as nice as Scheme :-) for web applications in ViaWeb? He used CPS because full continuations weren't available; maybe Scheme could do it nicer. -- .i mi'e snan .i mi rodo roda fraxu ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
RE: [Chicken-users] an ode to Spiffy
Felix, Hm. Could you try this, please: [...] $ ./repltest #; (thread-start! (lambda () (let loop ((i 0)) (print i) (thread-sleep! 1) (loop (add1 i) ; from now on you should still be able to eval expressions... That worked out of the box for me. [This is normally done in srfi-18.scm, but is disabled on Windows. Should this work with cygwin (requires select(2)), I'll disable it exclusively for Windows/MSVC (which doesn't have select(2) on file/stdio fd's)] Please, do so! Thanks a lot, Dominique ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] an ode to Spiffy
On Thu, 26 May 2005 11:35:16 +0200 felix winkelmann [EMAIL PROTECTED] wrote: On 5/26/05, Peter Busser [EMAIL PROTECTED] wrote: BTW, while talking about SXML, has anyone looked at getting LAML to work on Chicken? (http://www.cs.auc.dk/~normark/laml/) I have started once but lost interest. It shouldn't be too hard to port, though... (Hint, hint!) It may look a bit silly and ugly, but some time ago I made something that looks like that (if my guess about what LAML is is correct -- couldn't read the papers yet). It's at http://www.inf.ufrgs.br/~mario/english/utils/web-scheme Disclaimer: - I made it without looking for previous work about this topic. So, if some ideas are badly implemented or if there things that just look too silly, it's my fault. - The code is far from being good (horrible, in fact :-)) Originally it was just an attempt to get rid of some even more ugly scripts I use to generate headers and footers to some of my html pages and to use some programming stuff embedded in web pages with a cleaner syntax. Now it's not even that because I didn't convert those pages. :-) Best whishes, Mario ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users