Re: [Rest2web-develop] ConfigObj Commit
Brought to you by:
mjfoord
From: Michael F. <mi...@pc...> - 2005-07-08 09:11:57
|
Nicola Larosa wrote: [snip..] >>I *might* have some time during the day to look at the validate issues. >>(type checking and type conversion). >>First of all I'll add stringify and transforming validation. >>This will do the type conversion when you write files and when you validate. >> >>Can you think of any config information you might want to store where >>the *type* of the value will be ambiguous ? >>For example any config options where you might want a string or a number ? > > > A phone number, or zip code, could be ambiguous. > But seeing as you *specify* what you want, in these cases you probably want to leave it as a string. See below about the fact that I'm not *really* suggesting *automatic* type conversion. As you say in the other email - it's a bit like duck typing, the conversion is only done if you actually need (specify) it. > > >>The key thing is having a good standard set of validate functions that >>take care of all the common cases . >>Basic types : >> >> float >> decimal >> integer >> string >> date/time >> boolean >> None >> lists of any of these >> >>All these basic sorts it would be *very* simple to detect and >>automatically convert. > > > Simple, yes. Not *very* so in the date/time case, I fear. > Sure - there are modules that will attempt to cover the most common ways of specifying dates though. I *don't* think I'm really suggesting *automatic* type conversion - you still use the ``validate`` method and *specify* in your configspec what conversion/check to apply to each value. I can write enough general case functions that will cover all the above examples - and anything else that you will need. According to YAGNI I shouldn't write anything you don't actually want - so give me your use cases and I'll work to those..... The above ones are obvious though I guess..... Best Regards, Fuzzball http://www.voidspace.org.uk/python |