How to reuse objects in different execution
#1
Hello to everyone. My first post :-) ... clemency, please ;-)
I wrote a plugin (starting from an existing one).

Every click on a file/folder my default.py is called.

In default.py I use an object 'o' and I do someting like:
<default.py>
...
o = MyClass()
o.load()
for elem in o.elems():
...elem.doSomething()
...
...

o.load() is time consuming.
I'd like to know if is it possible to store objetc 'o' in the first execution of default.py and use it next times.
something like (I know thant xbmc.getCache and xbmc.setCache o not exist) :
<default.py>
...
o = xbmc.getCache('myobject')
if not o:
...o = MyClass()
...o.load()
for elem in o.elems():
...elem.doSomething()
xbmc.setCache(o, 'myobject')


Or do something similar to 'plugin scope', 'plugin init', 'plugin terminate' exist? (or plugin are stateless?)

Alternative solution is to use files to store object. Right?

Thanks and regards

zulio
Reply
#2
see if the pickle module is what you want.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#3
>> see if the pickle module is what you want.
Ok ... pickle is the right solution to caching in files.

I'd like to know if there is a xbmc support for caching objects or to save data in "plugin scope".

I suppose that the answer is "no" :-) ...

thx a lot

zulu
Reply

Logout Mark Read Team Forum Stats Members Help
How to reuse objects in different execution0