Re: Saving data after each action
- From: Ulrik Sverdrup <ulrik sverdrup gmail com>
- To: SanskritFritz <sanskritfritz gmail com>
- Cc: Kupfer list <kupfer-list gnome org>
- Subject: Re: Saving data after each action
- Date: Thu, 3 Mar 2011 15:56:03 +0100
2011/3/3 SanskritFritz <sanskritfritz gmail com>:
>> Saving "directly" would be better IMO, but then we need some
>> notification mechanism upwards from the plugins into Kupfer that data
>> has changed. That would be much superior to saving everything all the
>> time. 1 hour is just the period of the rescan cycle, so the save cycle
>> matches that.
>
> Ah so there are design limitations. The notification approach you suggested
> also involves changes in a plugin as well, I guess?
>
Yes. At save time, kupfer just checks if the plugin implements certain
methods and if it does, it calls them to get the save data. So plugins
don't write files by themselves (they shouldn't). And there is no
notification of changes in the protocol at the moment. (It's as simple
as possible), this is the save/restore implementation in the Trigger
plugin:
class Triggers (Source):
# ...
def config_save(self):
return {"triggers": self.trigger_table, "version": self.version}
def config_save_name(self):
return __name__
def config_restore(self, state):
self.trigger_table = state["triggers"]
return True
The unused version field is there for future use if needed. The save
data must be "simple" (in this case it's a dict of string -> (string,
string, PUID) mapping, where PUID a kupfer persistent id which is an
object that in some way identifies an object in Kupfer's catalog or in
some cases serializes the object)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]