mirror of https://github.com/fmartingr/iosfu.git
Plugins now store output in cache. Fixes #13
This commit is contained in:
parent
4b2f9b7387
commit
c921f97e01
|
@ -136,7 +136,7 @@ class Section(Component):
|
|||
def get_context(self):
|
||||
if self.backup and self.plugin:
|
||||
plugin = self.plugin(backup=self.backup)
|
||||
self.context = plugin.__do__()
|
||||
self.context = plugin.do()
|
||||
|
||||
def render(self, *args, **kwargs):
|
||||
"""
|
||||
|
|
|
@ -39,7 +39,14 @@ class BasePlugin(object):
|
|||
Main function called by plugin library.
|
||||
"""
|
||||
if self._backup:
|
||||
return self.__do__(*args, **kwargs)
|
||||
cached = self._backup.cache(self.__slug__)
|
||||
if cached is None:
|
||||
result = self.__do__(*args, **kwargs)
|
||||
self._backup.cache(self.__slug__, result)
|
||||
self._backup.write_data_file()
|
||||
return result
|
||||
else:
|
||||
return cached
|
||||
else:
|
||||
raise Exception(
|
||||
'Plugin {0} need a backup instance to work with'.format(
|
||||
|
|
Loading…
Reference in New Issue