|
From: Chris S. <so...@st...> - 2011-09-06 22:05:57
|
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...")
>
> 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 <thomsonreuters.com>***
>
>
> Phone: 763-450-4776
> Fax: 763-450-4710
> gar...@th... <mailto: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
|