|
From: Arve K. <arv...@gm...> - 2007-05-14 19:44:56
|
On 5/14/07, Michael Foord <fuz...@vo...> wrote:
>
> Arve Knudsen wrote:
> > Hi
> > I have a
> > problem with configobj/validate (in general a great combination!) that
> > keeps cropping up. If I forget to include a comma (',') when defining
> > a list value in my configuration file, it is translated into a string
> > (even though its specified type is 'list'). The fix is simply to add a
> > comma to the end of the configuration value. Is there any reason for
> > this behaviour? I find it rather painful since I have to check in my
> > own code whether supposed list values from configobj are actually
> > lists or strings.
> Can you post a minimal config and validation file that illustrates the
> problem, and I'll look at it.
# Config
values = val1
# Reading config in Python
import configobj, validate
conf = configobj.ConfigObj("test.cfg", configspec={"values": "list"})
vdt = validate.Validator()
conf.validate(vdt)
# The configuration now contains a string value for parameter "values"
In general, lists without commas aren't lists. :-)
Yes, that much is obvious.
I guess if an item is explicitly specified as a list then coercing a
> string into a single member list *sounds* like the right behaviour
> (rather than raising an error). Anyone else have any opinions?
>
I would like this behaviour, otherwise the validation should raise an error
instead of silently returning a string when a list was specified in the
validation schema.
Thanks,
Arve
|