|
From: Chris J. <cm...@te...> - 2010-02-01 14:00:12
|
Hey I'm using the excellent validation features to convert config files into the correct types, and it's working very well so far. I hacked something up that generates the configspec on the fly based on my own internal tree of default values, which has been a nice timesaver. However, I'm now trying to extend my application and I'm struggling to conceptualise how I'm going to validate the config (and more importantly, convert the types automatically). The problem is that the config section for the new feature is recursive. It's intended to describe a particular layout of widgets in my application, so the same layout can be recreated when starting the application. (the application is a tiled terminal emulator, http://www.tenshu.net/terminator) The config structure would be something like: [layouts] [mydebugginglayout] [window0] type = Window [child1] type = Terminal [child2] type = VPaned [child3] type = HPaned [child4] type = Terminal [child5] type = Terminal [child6] type = Terminal I'm not super happy about the windowN/childN section names, but storing those as lists doesn't seem to fit the configobj style, so I'm expecting to autogenerate them. Given that this can essentially nest infinitely, how would I write a configspec for it? Would it make more sense to store the children of each level as a list and treat it as a string, then recursively validate each child object? I'm not sure that any of what I've just written makes sense, let me know if I can clarify anything. Thanks very much for a great config file system :) Cheers, -- Chris Jones cm...@te... www.tenshu.net |