|
From: <gar...@th...> - 2011-09-06 23:27:51
|
Hi Chris and Michael,
Sorry, I spoke too soon. Not sure what I did just a few minutes ago, but
it works now as you mentioned.
Thanks!
Gary
From: Chris Sontag [mailto:so...@st...]
Sent: Tuesday, September 06, 2011 6:22 PM
To: con...@li...
Cc: Siaw, Gary (Professional)
Subject: Re: [Configobj-develop] default values not being set with
validation.
Hi Gary,
Are you saying that you have inspected the Python object (self.config)
and, after validation, it does not have those keys?
Or are you saying that you later call self.config.write() and those keys
are not written out?
Those are two different things. If the Python object has those keys
(which it should), the values will be the defaults.
Chris
On 9/6/11 7:13 PM, gar...@th... wrote:
Thanks for the quick responses!
Unfortunately, that is not what happens.
If I remove the lines so that my config_file looks like this:
[Environment]
name = 'qapod5'
and have the same configspec, the defaults are not put in.
-----Original Message-----
From: Michael Foord [mailto:fuz...@vo...]
Sent: Tuesday, September 06, 2011 5:19 PM
To: con...@li...
Cc: Siaw, Gary (Professional)
Subject: Re: [Configobj-develop] default values not being set with
validation.
Hey Gary,
Chris is correct - those values are not "missing", they exist but are
set to the empty string. Remove them and the validation defaults should
be filled in. Alternatively write your own validation functions that
interpret and empty value as missing and uses the default instead.
The validate module documentation shows how to write validation
functions.
All the best,
Michael
On 6 Sep 2011, at 23:01, Chris Sontag wrote:
Hi Gary,
I'm usually just a lurker on this list, but try taking
"services" and
"deploy_sso" out of your config file. Right now they are set to empty
strings. If they come out, they will be filled with default values (in
self.config) after your validate() call.
Chris
On 9/6/11 5:36 PM, gar...@th... wrote:
Hello there, thanks for this library tool!
Im trying to incorporate configobj-4.7.2 into an object
to read
configuration files with default values. The configobj can load the
configurationfile fine, but the configspec default values are not being
read in, and therefore validation fails.
not sure if my code is at fault.
What steps will reproduce the problem?
1.
Im loading code like this:
config = ConfigObj( infile=self.config_file,
configspec=self.config_spec,
encoding='latin-1',
create_empty=True,
unrepr=True,
stringify=True,
)
2.
my config_file looks like this:
[Environment]
name = 'qapod5'
services =
email =
deploy_sso =
3.
my configspec looks like this:
[Environment]
name = string()
services = list(default=list(''))
email = string(default="tes...@th..."
<mailto:tes...@th...> )
deploy_sso = boolean(default=False)
4. my validator code looks like this:
val = Validator()
test = self.config.validate(val, preserve_errors=True,
copy=True)
with the configspec above, i would expect that the
loaded configobj
would have the defaults after being validated with the Validator.
However, i get this error:
ValidateError: [([u'Environment'], 'deploy_sso',
VdtTypeError(u'the
value "" is of the wrong type.',)), ([u'Environment'], 'services',
VdtTypeError(u'the value "" is of the wrong type.',))]
Is my configspec not written properly?
Thanks,
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
Gary Siaw
Application Engineer, Paisley
Thomson Reuters
Phone: 763-450-4776
Fax: 763-450-4710
gar...@th...
paisley.thomsonreuters.com
------------------------------------------------------------------------
------
Malware Security Report: Protecting Your Business,
Customers, and the
Bottom Line. Protect your business and customers by
understanding the
threat from malware and how it can impact your online
business.
http://www.accelacomm.com/jaw/sfnl/114/51427462/
_______________________________________________
Configobj-develop mailing list
Con...@li...
https://lists.sourceforge.net/lists/listinfo/configobj-develop
------------------------------------------------------------------------
------
Malware Security Report: Protecting Your Business, Customers,
and the
Bottom Line. Protect your business and customers by
understanding the
threat from malware and how it can impact your online business.
http://www.accelacomm.com/jaw/sfnl/114/51427462/________________________
_______________________
Configobj-develop mailing list
Con...@li...
https://lists.sourceforge.net/lists/listinfo/configobj-develop
--
http://www.voidspace.org.uk/
May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing
http://www.sqlite.org/different.html
------------------------------------------------------------------------
------
Malware Security Report: Protecting Your Business, Customers, and the
Bottom Line. Protect your business and customers by understanding the
threat from malware and how it can impact your online business.
http://www.accelacomm.com/jaw/sfnl/114/51427462/
_______________________________________________
Configobj-develop mailing list
Con...@li...
https://lists.sourceforge.net/lists/listinfo/configobj-develop
|