Updates to self.pluginPrefs()

Posted on
Fri Jun 30, 2017 6:24 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Updates to self.pluginPrefs()

I'm looking to come up with a uniform way to store non-volatile data in my plugins so that I don't have to create a user space and plugin updates don't wipe out the data when they're installed (like they are if they're stored in the plugin package). I took a look at the self.pluginPrefs() dict a while back and discounted it--probably because I didn't know what I was doing. Now I'm second-guessing that decision.

Per plugin prefs file is automatically managed (created, loaded, updated).

So this means that I don't have to worry about blowing changes up to the server. I think this is the critical bit that I didn't understand. In testing, I would make a change to the self.pluginPrefs() dict and then take a look at the *.indiPref file and the change wouldn't be reflected there. If I opened the plugin configuration dialog and saved, then the change would appear in the *indiPref file. I know that the new value is still in self.pluginPrefs(), but I'd like to ensure that the new value gets blown down to the *indiPref file for 'permanent' storage such that the change won't be lost if there's a plugin shutdown, restart or whatnot. It doesn't appear that there's a way to force that to happen like there is with *.replacePluginPropsOnServer().

When is the *indiPref file itself updated by the server?
Am I being too cautious?

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Fri Jun 30, 2017 7:28 am
kmarkley offline
Posts: 185
Joined: Nov 15, 2016

Re: Updates to self.pluginPrefs()

I think you want
Code: Select all
indigo.server.savePluginPrefs()

Posted on
Fri Jun 30, 2017 8:39 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Updates to self.pluginPrefs()

kmarkley wrote:
I think you want
Code: Select all
indigo.server.savePluginPrefs()


Thanks. I will definitely use that call for my I7 plugins.

Appreciated!

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Fri Jun 30, 2017 9:03 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Updates to self.pluginPrefs()

I have a directory ~/documents/pluginname where the plugin stores Jason files etc. that seems to be easy for users. They can make a backup copy or can delete that directory -- to restore or start from scratch in an easy way.


Sent from my iPhone using Tapatalk

Posted on
Fri Jun 30, 2017 9:26 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Updates to self.pluginPrefs()

DaveL17 wrote:
When is the *indiPref file itself updated by the server?


When they need to be flushed to disk. It's not immediate but it is periodically flushed to disk. We've not seen any issues.

DaveL17 wrote:
Am I being too cautious?


Probably, but feel free to force it if you want. It'll just cause more disk and Indigo Server activity. I would recommend storing prefs there rather than outside the Indigo directory - less of a chance a user will accidentally delete prefs since it's somewhat hidden from them. And Indigo will always preserve the Preferences directory during upgrades.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Jun 30, 2017 9:30 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Updates to self.pluginPrefs()

kw123 wrote:
I have a directory ~/documents/pluginname where the plugin stores Jason files etc. that seems to be easy for users. They can make a backup copy or can delete that directory -- to restore or start from scratch in an easy way.


Sent from my iPhone using Tapatalk

Thanks Karl. I did that with my Announcements plugin, but I'd rather not have to worry about establishing a user space (like ~/documents/pluginname) if I can help it. This seems to introduce complexity (like if a user moves Indigo to a new machine) that I may be able to avoid entirely by using pluginPrefs. In my initial tests this seems to be working well for an I6 compatible plugin and I with the addition of API 2.0, I think it will be killer for I7 plugins.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Fri Jun 30, 2017 9:37 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Updates to self.pluginPrefs()

jay (support) wrote:
... feel free to force it if you want. It'll just cause more disk and Indigo Server activity. I would recommend storing prefs there rather than outside the Indigo directory - less of a chance a user will accidentally delete prefs since it's somewhat hidden from them. And Indigo will always preserve the Preferences directory during upgrades.

Thanks Jay. I'm testing now, and it seems to be working well. I think I may have found a way to 'trick' the server into saving immediately (for pre API 2.0), but I haven't taken that drastic of a step yet.

Turns out that I also misunderstood another thing about pluginPrefs. I was under the impression that anything I added needed to also be setup in PluginConfig.xml--but it seems I can add anything I want (within reason) to self.pluginPrefs and it will be blown to the *indiPrefs file; no control (hidden or otherwise) needed. Makes things simpler for me.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest