Subject: Re: [PATCH] services: radicale: Use define-configuration.

From: Liliana Marie Prikler <[email-masked]>
Date: Mon, 11 Mar 2024 06:20:41 +0100

Hi Juliana,

Am Sonntag, dem 10.03.2024 um 22:04 -0400 schrieb Juliana Sims:
> [...]
> 
> +(define (radicale-serialize-field field-name value)
> +  ;; XXX We quote the un-gexp form here because otherwise symbol-
> literals are
> +  ;; treated as variables. We can get away with this because all of
> our other
> +  ;; field value types are primitives by the time they get here so
> are printed
> +  ;; the same whether or not they are quoted.
> +  #~(format #f "~a = ~a\n" #$(uglify-field-name field-name)
> '#$value))
You should not need to quote symbols here.

> +(define (radicale-serialize-boolean field-name value?)
> +  (radicale-serialize-field field-name (if value? "True" "False")))
> +
> +(define (radicale-serialize-comma-separated-string-list field-name
> value)
> +  (radicale-serialize-field field-name (string-join value ", ")))
> +
> +(define radicale-serialize-file-name radicale-serialize-field)
> +
> +(define radicale-serialize-non-negative-integer radicale-serialize-
> field)
> +
> +(define radicale-serialize-string radicale-serialize-field)
> +
> +(define radicale-serialize-symbol radicale-serialize-field)
> +
> +(define ((sanitize-delimited-symbols syms location field) value)
> +  (cond
> +   ((not (maybe-value-set? value))
> +    value)
> +   ((member value syms)
> +    (uglify-field-name value))
> +   (else
> +    (configuration-field-error (source-properties->location
> location)
> +                               field
> +                               value))))
> +
> +;; Section configuration types
> +
> +(define-configuration radicale-auth-configuration
> +  (type
> +   maybe-symbol
> +   "The method to verify usernames and passwords. Options are
> @code{none},
> +@code{htpasswd}, @code{remote-user}, and @code{http-x-remote-user}.
> +
> +This value is tied to @code{htpasswd-filename} and @code{htpasswd-
> encryption}."
> +   (sanitizer
> +    (sanitize-delimited-symbols '(none htpasswd remote-user http-x-
> remote-user)
> +                                (current-source-location)
> +                                'type))
> +   (serializer radicale-serialize-field))
Note the mismatch between documented and stored type:  Your type is
"maybe-symbol", but you store strings.  Instead, you can a) move the
the logic to uglify the name to radicale-serialize-symbol or define a
radicale-serialize-uglified-symbol variant if you need the normal
radicale-serialize-symbol, or b) document that you actually take
strings.  Of course, you can also think of other solutions.

Hint: I'd personally prefer solution a).

Cheers