How are you guys storing settings along with your tools?
I’m thinking of use-cases similar to QSettings, maybe you’re even using QSettings. I’m looking to persistently store settings used in custom tools both locally but also centralised; similar to userSetup.py of Maya. Would you use a Python module, like userSetup.py? Or a JSON/YAML? Why, why not?
On a related note, how do you deal with defaults? E.g. when workspace.mel of Maya doesn’t exist, a default is created. Are you hosting defaults in code, or in another settings file - and if so, how do you solve the chicken or egg problem? If not, are you concerned about hard-coded values?
I always use QSettings. The good thing is that you can always specify a default value if there is not a user value already. Also, by using this method it is OS agnostic.
Thanks guys! As it happens, the question was asked simultaneously on the Maya-Python list - posting it here for the additional answers: Redirecting to Google Groups
Now, where do you store your settings? Something like this?
pythonpath/mypackage/settings.ini|yaml|json
Then what about a multi-user setup? Something like this?
/home/marcus/mypackage_settings.ini|yaml|json
Then what about a multi-site setup? Something like this?
//network/mypackage_settings.ini|yaml|json
Then what about when the network isn’t available, and what about slow networks/large configurations?
Could you expand on this? Isn’t JSON and YAML and pretty much any file-based persistence also OS agnostic? What about the settings do you find OS-dependent? I could see how this is a benefit for things like C++ where I/O may differ per platform, but in Python I’m not so sure!
Last time I had to do this sort of thing, I used ConfigParser and associated files. It wasn’t great, because I spent of lot of time converting to the right data types from the strings passed. Next project is json.
i just use a lot of json, sometimes in maya i will use OptionVars. In the past for quick and dirty persistence i have used the pickle modual to just searlize a whole python object that carries my settings.
Thanks guys. For those not using QSettings, are multiple users accessing/modifying a single set of settings at any one time? If so, have you ever had issues with corruption?
Thanks cgjedi. Would you mind posting an example of that? It might be the case that JSON and YAML also does this, but I’m not sure if I’m thinking of the same thing.
Yes, thank you, I’m familiar with QSettings. My question was about whether or not you meant the same as JSON and YAML also does. Sorry for the confusion!