[racket] formlet-fill

From: Jordan Schatz (jordan at noionlabs.com)
Date: Mon Nov 21 14:00:10 EST 2011

On Mon, Nov 21, 2011 at 06:32:18AM -0700, Jay McCarthy wrote:
> I can imagine implementing something like...
> 
> (define record-formlet
>             (formlet
>              ;; Define the input format
>              ([name (hash-ref this 'name)]
>               [company (hash-ref this 'company)]
>               [address (hash-ref this 'company)]
>               [city (hash-ref this 'city)]
>               [state (hash-ref this 'state)]
>               [zip (hash-ref this 'zip)])
>              ;; Define the display format / input mapping
>              (#%# ,{(to-string (required (text-input))) . <=> . name}
>                   ,{(to-string (required (text-input))) . <=> . company}
>                   ,{(to-string (required (text-input))) . <=> . address}
>                   ,{(to-string (required (text-input))) . <=> . city}
>                   ,{(to-string (required (text-input))) . <=> . state}
>                   ,{(to-string (required (text-input))) . <=> . zip})
>              ;; Define the output format
>              (values name company address city state zip)))
> 
> Does that seem more palatable?
Yes... In my usage I think I would always be giving it a hashtable, and
getting a hashtable back, and the names on the right hand side of the
formlet would correspond to the keys in the input and output hashtable.

I see that it might not be generally useful and probably doesn't belong
in web-server/formlets

> Your version that breaks mainly breaks because you are mutating the
> record and recomputing the formlet, rather than saving the formlet in
> the continuation for both the display and the processing.
So is this http://noionlabs.com/formlets/save-formlet.rkt the general
pattern of how others are writing their formlets? (using a maker /
generator function to create a form with initial values, and keeping it
in a variable for the processing step?)

Are there any open sourced web apps built in racket where I could
observer how people are using racket's features?

Shalom,
Jordan


Posted on the users mailing list.