RFC: Bridge AppConfig and Config::Model
am 22.11.2007 13:33:21 von dominique.dumontHello
I've had a request to be able to use Config::Model [1] on top of
AppConfig [2] to have an easy configuration editor
(Config:::Model::CursesUI [3])
To provide a configuration editor, Config::Model needs a description
(i.e. a model) of the configuration variables.
AppConfig also have its own representation of configuration variables
(constructed with AppConfig::define method).
Currently, I can see 2 ways of using AppConfig and Config::Model:
1. Rely on AppConfig representation and create a valid model for
Config::Model
2. Start from a valid Config::Model, and hook AppConfig so that each
new variable setting is checked by Config::Model. The hook would
use VALIDATE with a code ref.
Solution 1 needs:
- code to convert AppConfig data structure to Config::Model data
structure.
- code to read config data from AppConfig and load it into the
configuration instance created with Config::Model
- code to write back config value modifed by the editor into AppConfig
Solution 2 needs:
- A valid model for Config::Model (taking into account AppConfig
limitations)
- some code to create AppConfig data structure from the "valid model"
mentioned above.
- The same read/write code as solution 1
* sol 1 Pro & Cons:
+ Quite transparent to developer
- No validation besides the one done by AppConfig
- No help for each parameter
* sol 2 Pro & Cons:
- developer must write a config model (taking into account the
structure that can be mapped to AppConfig, mostly a unique config
class with leaf, list or hash elements)
+ developer can add more validation criteria
+ developer can add help for parameters
Anyway, I think I can provide both modes in a module named (If Andy
agrees) AppConfig::ToConfigModel.
What do you think ?
Do you have other suggestion for a module name ?
Should I provide the 2 solutions in 2 modules ? Like
AppConfig::ToConfigModel and AppConfig::FromConfigModel.
Thanks for any feedback
[1] http://config-model.wiki.sourceforge.net/
http://search.cpan.org/dist/Config-Model/
[2] http://search.cpan.org/~abw/AppConfig-1.66/
[3] http://freshmeat.net/projects/config-model-cursesui/
http://search.cpan.org/dist/Config-Model-CursesUI/
--
Dominique Dumont
"Delivering successful solutions requires giving people what they
need, not what they want." Kurt Bittner