[PEAK] plugins, dynamic module loading

Phillip J. Eby pje at telecommunity.com
Mon Nov 24 19:59:07 EST 2003


At 06:51 PM 11/24/03 -0800, darryl wrote:
>Question:
>
>Config files are 'read-only' or at least so-much as the support
>that peak provides is for reading.
>
>If i'm keeping config values in an ini file and wish to
>write out changed config values for the next time
>the app runs, is there a preferred peak-ish way for this?

No.  Although peak.running.tools.version actually has some code that writes 
an .ini file.  But the .ini file in question isn't intended for use by humans.

If you need to edit a config file, it would probably be best to follow the 
example of the 'version' tool, as it edits the file in such a way that the 
original file isn't overwritten until/unless the new copy is successfully 
written.  And, it uses the peak.storage transaction API, so you can have 
the config file update be part of a larger transaction.

I imagine that you could in fact write code to edit an .ini file in more 
sophisticated ways than that code does.  I just haven't had a need for it yet.


>Also is there a way to re-read a config file.
>i.e. if i do a
>
>binding.Obtain(PropertyName('bot.modules'))
>
>and then later edit the ini file can i re-Obtain the values?

Only by re-creating the components involved.  Presumably, one could create 
a config file loader subclass that would look for specific values and 
re-interpret them, but I have not had a need for such a thing as yet.




More information about the PEAK mailing list