Hi,

I've been experimenting with a runtime configuration file, following the ideas that were put on the list in October.

These are the files needed, diffed to the current CVS head

http://www.fambus.nl/~ebus/freevo/runtime_config.xml
http://www.fambus.nl/~ebus/freevo/config.init.diff
http://www.fambus.nl/~ebus/freevo/runtimexml.py

I put the runtimexml.py in src/config/ and the xml file goes in your default config path.

At the moment, the class is very simple. It can only load an XML, parse the data in it and set the appropriate config.XXXX values. The format of those valuenames is config.PATH_TO_THE_ELEMENT_VALUE_NAME.

So, if we make a file like this:

<freevo>
   <tv>
      <record>
         <var name="padding">600</var>
      <record>
   </td>
</freevo>

It would set the value 600 to config.TV_RECORD_PADDING. This way we could group items on more then one level. The only 'problem' with this is that two items can have the same path, because spaces in variable names are converter into underscores (_).

Freevo polls the file every 5 seconds. When the file is changed on disk, Freevo sees the change and reloads the config. Before it does this, it puts back a backup of the settings before the previous load. This way, when you remove a setting from the file, the default setting from local_config.py takes over.

You can use the set_value() method to write a config value to the active config and the file on disk. To set the value config.AUDIO_PREFERED_PLAYER to 'xine', you would use:

set_value(['audio'], 'prefered player', 'xine')

The first parameter specifies the full path to the config variable.

What the class needs is some handler-mechanism to report config changes to specific modules. Some modules initialize their own config values based on global settings. Those values should be re-initialized with the new value. If possible at all...

Well, that's about it. It this something we can use? It's something I put toghether in one morning, so expect some bugs and strange behaviour ;)

Eric


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
_______________________________________________
Freevo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to