Did some work on the reload manager, as well as removed
the rollback importer from server.py
This commit is contained in:
parent
5ecbff32f6
commit
02ffa832f6
5 changed files with 93 additions and 31 deletions
18
mixins.py
18
mixins.py
|
|
@ -1,18 +1,20 @@
|
|||
|
||||
"""
|
||||
The ReloadMixin class is meant as an example, but should work
|
||||
for basic purposes as a mixin inheritance.
|
||||
"""
|
||||
class ReloadMixin():
|
||||
"""
|
||||
This class is a generic reload mixin providing the two
|
||||
methods required to cache and reload an object.
|
||||
"""
|
||||
def cache(self, reloader, do_save=True):
|
||||
cache_dict = {}
|
||||
if do_save:
|
||||
if self.save and callable(self.save):
|
||||
self.save()
|
||||
else:
|
||||
raise ValueError("This object does not have a save function, you must pass save=False for this object type.")
|
||||
raise ValueError("This object does not have a save function, you must pass do_save=False for this object type.")
|
||||
|
||||
for key, value in self.__dict__.iteritems():
|
||||
if not callable(value):
|
||||
cache_dict[key] = value
|
||||
|
||||
reloader(self, cache_dict)
|
||||
reloader.cache_object(self)
|
||||
|
||||
def reload(self, cache):
|
||||
for key, value in cache.iteritems():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue