mirror of
https://github.com/evennia/evennia.git
synced 2026-03-29 12:07:17 +02:00
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:
parent
91ec33b9a7
commit
464aa8ca9e
3 changed files with 38 additions and 28 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue