XDM
XDM copied to clipboard
How can a plugin keep state?
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?
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
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