Re: [Rest2web-develop] rest2web and ConfigObj
Brought to you by:
mjfoord
From: Michael F. <mi...@pc...> - 2005-08-10 15:12:58
|
Nicola Larosa wrote: > [Is it intended, this not going to the list?] > No - a mistake. Sorry > > >>>I've implemented (and checked in) defaults as discussed. I've done one >>>test - more appreciated ;-) >>> >>>It uses the 'default' keyword in checks, and adds a new attribute >>>'defaults' on sections. >>> >>>If a keyword is missing but a default is supplied, then the default is >>>used. (The default *is* still passed to the check so that type >>>conversion can be done). >>> >>>If a keyword is missing and no default is supplied then a >>>ValidateMissingValue error is raised. (Check fails). >>> >>>The write method doesn't write out any values that come from defaults. >>>If a whole section is missing the empty marker is still written out. >>> >>>Setting a value that was previously obtained from a default, removes it >>>from the list of defaults - so it will be written out. > > > Wonderful, I'll check this ASAP. > > > >>>I *haven't* implemented a way of repeating whole sections in the configspec. >>> >>>If I *was* to do that I would probably do it by allowing you to name >>>sections of a ConfigObj with the magic value ``'__name__' = name`` >>> >>>You could then assign a section with (?) ``'__copy__' = name`` and it >>>will copy the section (including recursive subsections ?). >>> >>>I don't like magic values though...... It's also a nuisance as you'd >>>have to parse the whole thing and then go back through sorting out the >>>magic values :-) What to do with the ``write`` method would also be >>>interesting. (I'd probably *not* write out sections with '__copy__' as a >>>value, and delete '__copy__' if you assign to a value.. not easy though >>>in case someone sets a value in a *parent* section - have to walk up the >>>parents deleting the '__copy__' value as well....). > > > Yuck, too complicated. I'll first try your suggestion to manually assign > configspecs to sections, even if it's already been used in another one. > No problem - this *will* work. The validate method just uses the 'configspec' attribute for checks - so you can assign to it easily. You still have to do it manually of course... :-) > The only thing really missing now is having "lists of sections", for the > cases when their number cannot be determined in advance. Maybe some easy > workaround can be found. I don't understand what you want. If you give me an example I'll think about it. It sounds like you need a way of referencing (naming) individual sections. Is this just for the programmer - or for the system administrator (the user). If you just want to obtain a list of all the sections in a config file - then that would be quite easy to obtain.... Regards, Fuzzy http://www.voidspace.org.uk/python > > -- > Nicola Larosa - ni...@te... > > When I thought life had some purpose - Then I thought I had some choice > (I was running blind) > And I made some value judgments - In a self-important voice > (I was outa line) > But then absurdity came over me - And I longed to lose control > (into no mind) > Oh all I ever wanted - Was just to come in from the cold > -- Joni Mitchell, Come in from the cold, Night Ride Home, 1991 > |