mirror of
https://github.com/evennia/evennia.git
synced 2026-04-02 22:17:17 +02:00
20 lines
661 B
Python
20 lines
661 B
Python
|
|
class ReloadMixin():
|
|
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.")
|
|
|
|
for key, value in self.__dict__.iteritems():
|
|
if not callable(value):
|
|
cache_dict[key] = value
|
|
|
|
reloader(self, cache_dict)
|
|
|
|
def reload(self, cache):
|
|
for key, value in cache.iteritems():
|
|
if self.__dict__[key] != value:
|
|
self.__dict__[key] = value
|