Re: [Rest2web-develop] Repeated Section
Brought to you by:
mjfoord
From: Michael F. <mi...@pc...> - 2005-08-12 11:39:22
|
Michael Foord wrote: > Hello All, > > I've just committed changes to ConfigObj that implement repeated > sections using the '__many__' section name in the configspec. > > The actual code is about twenty lines - plus nearly 70 lines of tests. > > If a section of a configspec (including the root section) has a > sub-section called '__many__' - then *this* is the configspec that will > be applied to *all* sub-sections in that section. The implied restriction here is that if you supply any other specs in your configspec they will be ignored - and just the '__many__' one used. This could be changed; either to raise an error - or to 'update' the dictionary (was update around as a method of dictionaries in python 2.2 ?) rather than replace it (so that the '__many__' and any additional checks could be used). I've done another minor commit to correct a couple of whitespace errors in a docstring. I'm now (again/still) working on getting the documentation up to date. Regards, Fuzzy http://www.voidspace.org.uk/python > The '__many__' > sub-section can itself have nested sections, including nested '__many__' > sections. > > E.g. > > [cats] > > [[__many__]] > age = float(0, default=5) > height = float(default=0.25) > mood = option(grumpy, aloof, vain, default=aloof) > [[[description]]] > coat = option(brown, grey, black, "tortoise shell", default=brown) > [[[fleas]]] > [[[[__many__]]]] > bloodsucker = boolean(default=True) > children = integer(0, default=1000) > > The above configspec creates a section called 'cats'. Any subsection in > 'cats' must match the '__many__' configspec. So each cat has several > attributes (including a subsection called 'description'). Each cat can > also optionally have many fleas.... > > Because all the checks have defaults - if you create any empty cats and > then call validate, the default values will be filled in. > > Nicola - you will need to properly format the doctests - as well as > check that I haven't broken anything and that it works as advertised. > > (By the way floats become numbers like 3.000000001 when converted > backwards and forward. Decimal would be better - but is a Python 2.4 > module. This might not matter.) > > Best Regards, > > > Fuzzyman > http://www.voidspace.org.uk/python > > > > ------------------------------------------------------- > SF.Net email is Sponsored by the Better Software Conference & EXPO > September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA > Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf > _______________________________________________ > Rest2web-develop mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/rest2web-develop > > > |