[gambit-list] Spork & Session variables
per.eckerdal at gmail.com
Sun Sep 27 04:50:44 EDT 2009
Here's an example that uses session variables:
(define c (spork-serve port: 8088))
(define var (make-session-variable "[NOT INITED]"))
(add-spork c ("")
`(h1 "Value: " ,(var))
`(a (@ (href "edit-value")) "Edit value")))
(add-spork c ("edit-value")
(let* ((ret (show
(@ (method "POST")
(input (@ (type "text")
(input (@ (type "submit"))))))))
(value-pair (assoc "value" ret))
(value (and value-pair
(var (or value "[NO VALUE]"))
The web app should be accessible at http://localhost:8088/ Not the
most beautiful code around, but for me it works.
Using the session variable from the REPL won't work, because you are
not inside of an HTTP request; In Spork's implementation of session
variables, accessing or editing a session variable from the REPL is
nonsensical. It might be useful to add functions to change the dynamic
environment to a certain session, but I haven't done that yet.
26 sep 2009 kl. 15.24 skrev Nicola Archibald:
> Has anyone had any success with using session variables within spork?
> The only real documentation for session variables is within the
> blackhole-libs docs, which state to just (define variable
> (make-session-variable)) which should give the default value of #f to
> the variable... But doing so raises exceptions in 'cookie-get-changes'
> whenever attempting to read or write the variable (using (variable)
> (variable value) respectively, of course).
> If anyone has gotten them working can they share insights? or if
> Per/Mickael has any suggestions?
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
More information about the Gambit-list