|
From: Fuzzyman <fuz...@vo...> - 2005-12-13 10:13:31
|
Hello all,
There is a bug in the current validate code.
It doesn't correctly handle lists as default values - how did that get
past the tests ?
In fact commas in default values *seem* to break it completely. No worry
- I can fix this, so far only with a *truly horrible* set of regular
expressions, but I'm sure they can be optimised.
The question is how do we want to specify list values as defaults in the
configspec ?
The current rationale (which doesn't work) uses the same syntax as
ConfigObj. This might sound logical - but it has an unfortunate side effect.
ConfigObj syntax is to treat any value with commas in as a list -
unless it is quoted. Because configspec values are part of an argument
list they need to be quoted anyway. this means the current syntax for a
normal value with commas is
checkname(default="'a value, with commas'")
Notice the *double* quotes ! Truly horrible IMO.
The alternative would be to indicate list values by surrounding with
square brackets :
checkname(default="[ 'val 1', 'val 2', 'val 3']")
The advantage is that it means you don't need to double quote default
values with commas. The disadvantage is that we now have a different
syntax for lists in the configspec and in the ConfigObj.
I don't think this is such a problem.
I wouldn't (initially) add any escape values - this would mean you
couldn't use quotes or square brackets inside list members.
The alternative is to build a 'full scale' parser for the configspec -
which I am reluctant to do. An alternative way of specifying defaults is
to use merge (the recursive update which will be in the new release of
ConfigObj).
Feedback appreciated - this changes the syntax of the configspec, so
it's a (relatively) important decision.
Thanks
Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
|