XDM icon indicating copy to clipboard operation
XDM copied to clipboard

How can a plugin keep state?

Open jmichiel opened this issue 11 years ago • 2 comments

I want to make a MediaAdder plugin that checks is a web resource has updated content since the last check. So I want to somehow keep track of the 'last check' time. Maybe also allow the user to manually set it so you can get all entries since a certain date. How would I best do that?

jmichiel avatar Nov 28 '13 13:11 jmichiel

either thru a config (instance save) or you write your own file (you have to take care of the instance safety) or anything else python has to offer

but the easiest way (also when you want the user to be able to set it manually) is a config field edit: little doc on config http://xdm.readthedocs.org/en/latest/plugin/index.html#adding-configuration

there are also hidden configs to keep track of state that should not be exposed i explained a little how hidden configs work here https://github.com/lad1337/XDM/issues/90#issuecomment-29221555

lad1337 avatar Nov 28 '13 16:11 lad1337

if this was a question on how to store more then just some keys i used a simple json file to store / cache some information in one plugin

https://github.com/lad1337/XDM-main-plugin-repo/blob/master/XEMNames/xemnames.py#L63

lad1337 avatar Jan 14 '14 16:01 lad1337