mirror of
https://github.com/evennia/evennia.git
synced 2026-03-22 07:46:30 +01:00
Put up a warning about not using BaseObject.at_init() at this time (it's not called, as per issue 188). Also removed the deprecated at_cache() hook (it doesn't work anymore now that the caching system is much more efficient and only caches once).
This commit is contained in:
parent
f1d743f14c
commit
1995f61d46
5 changed files with 18 additions and 23 deletions
|
|
@ -90,12 +90,11 @@ class Object(BaseObject):
|
|||
at_drop(dropper) - called when this object has been dropped.
|
||||
at_say(speaker, message) - by default, called if an object inside this object speaks
|
||||
|
||||
at_cache() - called when this typeclass is instantiated and cached
|
||||
at_server_reload() - called when server is reloading
|
||||
at_server_shutdown() - called when server is resetting/shutting down
|
||||
|
||||
at_server_shutdown() - called when server is resetting/shutting down
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class Character(BaseCharacter):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -137,7 +137,6 @@ class CmdSetObjAlias(MuxCommand):
|
|||
# save back to object.
|
||||
obj.aliases = aliases
|
||||
# we treat this as a re-caching (relevant for exits to re-build their exit commands with the correct aliases)
|
||||
obj.at_cache()
|
||||
caller.msg("Aliases for '%s' are now set to %s." % (obj.key, ", ".join(obj.aliases)))
|
||||
|
||||
class CmdCopy(ObjManipCommand):
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ class Object(TypeClass):
|
|||
|
||||
def at_init(self):
|
||||
"""
|
||||
OBS: CURRENTLY NOT CALLED!
|
||||
|
||||
This is always called whenever this
|
||||
object initiated -- both when the object
|
||||
is first created as well as after each restart.
|
||||
|
|
@ -96,14 +98,6 @@ class Object(TypeClass):
|
|||
"""
|
||||
pass
|
||||
|
||||
def at_cache(self):
|
||||
"""
|
||||
Called whenever this object is cached to the idmapper backend.
|
||||
This is the place to put eventual reloads of non-persistent attributes
|
||||
you saved in the at_server_reload() below.
|
||||
"""
|
||||
pass
|
||||
|
||||
def at_server_reload(self):
|
||||
"""
|
||||
This hook is called whenever the server is shutting down for restart/reboot.
|
||||
|
|
|
|||
|
|
@ -100,7 +100,9 @@ class Evennia(object):
|
|||
reactor.addSystemEventTrigger('before', 'shutdown', self.shutdown, _abrupt=True)
|
||||
|
||||
self.game_running = True
|
||||
|
||||
|
||||
self.run_init_hooks()
|
||||
|
||||
# Server startup methods
|
||||
|
||||
def sqlite3_prep(self):
|
||||
|
|
@ -140,6 +142,16 @@ class Evennia(object):
|
|||
initial_setup.handle_setup(int(last_initial_setup_step))
|
||||
print '-'*50
|
||||
|
||||
def run_init_hooks(self):
|
||||
"""
|
||||
Called every server start
|
||||
"""
|
||||
from src.objects.models import ObjectDB
|
||||
from src.players.models import PlayerDB
|
||||
|
||||
print "run_init_hooks:", ObjectDB.get_all_cached_instances()
|
||||
[(o.typeclass(o), o.at_init()) for o in ObjectDB.get_all_cached_instances()]
|
||||
[(p.typeclass(p), p.at_init()) for p in PlayerDB.get_all_cached_instances()]
|
||||
|
||||
def terminal_output(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -101,15 +101,6 @@ class SharedMemoryModel(Model):
|
|||
"""
|
||||
if instance._get_pk_val() is not None:
|
||||
cls.__instance_cache__[instance._get_pk_val()] = instance
|
||||
try:
|
||||
object.__getattribute__(instance, "at_cache")()
|
||||
except (TypeError, AttributeError), e:
|
||||
#print e, instance._get_pk_val()
|
||||
pass
|
||||
|
||||
#key = "%s-%s" % (cls, instance.pk)
|
||||
#TCACHE[key] = instance
|
||||
#print "cached: %s (%s: %s) (total cached: %s)" % (instance, cls.__name__, len(cls.__instance_cache__), len(TCACHE))
|
||||
cache_instance = classmethod(cache_instance)
|
||||
|
||||
def get_all_cached_instances(cls):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue