Added the ability to clear an object from the global cache. This is rarely

needed (and can be potentially dangerous if the object depends on certain
startup methods to run and/or holds temporary attributes on themselves -
these will all be lost due to a new instance being created. It is hoever
necessary when it comes to renaming Exits - since the Command on the exit
must then change name too, recaching the Exit will also update the command.
Resolves issue 223.
This commit is contained in:
Griatch 2012-04-15 21:46:43 +02:00
parent 91ec33b9a7
commit 464aa8ca9e
3 changed files with 38 additions and 28 deletions

View file

@ -41,7 +41,7 @@ from src.server.models import ServerConfig
from src.typeclasses import managers
from src.locks.lockhandler import LockHandler
from src.utils import logger, utils
from src.utils.utils import make_iter, is_iter, has_parent, to_unicode, to_str
from src.utils.utils import make_iter, is_iter, to_unicode, to_str
__all__ = ("Attribute", "TypeNick", "TypedObject")
@ -1447,3 +1447,11 @@ class TypedObject(SharedMemoryModel):
return any(True for hpos, hperm in enumerate(_PERMISSION_HIERARCHY)
if hperm in [p.lower() for p in self.permissions] and hpos > ppos)
return False
def flush_from_cache(self):
"""
Flush this object instance from cache, forcing an object reload. Note that this
will kill all temporary attributes on this object since it will be recreated
as a new Typeclass instance.
"""
self.__class__.flush_cached_instance(self)