Starting to remove obj.typeclass references. Server now starts and stops cleanly, but not yet tested with actual gameplay.

This commit is contained in:
Griatch 2014-12-22 21:46:52 +01:00
parent e214c036c8
commit a93d318121
3 changed files with 12 additions and 22 deletions

View file

@ -124,8 +124,7 @@ class ScriptDB(TypedObject):
obj = _GA(self, "db_player")
if not obj:
obj = _GA(self, "db_obj")
if obj:
return obj.typeclass
return obj
def __set_obj(self, value):
"""

View file

@ -232,8 +232,8 @@ class Evennia(object):
self.update_defaults()
#print "run_init_hooks:", ObjectDB.get_all_cached_instances()
[(o.typeclass, o.at_init()) for o in ObjectDB.get_all_cached_instances()]
[(p.typeclass, p.at_init()) for p in PlayerDB.get_all_cached_instances()]
[o.at_init() for o in ObjectDB.get_all_cached_instances()]
[p.at_init() for p in PlayerDB.get_all_cached_instances()]
with open(SERVER_RESTART, 'r') as f:
mode = f.read()
@ -305,11 +305,9 @@ class Evennia(object):
if mode == 'reload':
# call restart hooks
yield [(o.typeclass, o.at_server_reload())
for o in ObjectDB.get_all_cached_instances()]
yield [(p.typeclass, p.at_server_reload())
for p in PlayerDB.get_all_cached_instances()]
yield [(s.typeclass, s.pause(), s.at_server_reload())
yield [o.at_server_reload() for o in ObjectDB.get_all_cached_instances()]
yield [p.at_server_reload() for p in PlayerDB.get_all_cached_instances()]
yield [(s.pause(), s.at_server_reload())
for s in ScriptDB.get_all_cached_instances()]
yield self.sessions.all_sessions_portal_sync()
ServerConfig.objects.conf("server_restart_mode", "reload")
@ -325,19 +323,14 @@ class Evennia(object):
if mode == 'reset':
# don't unset the is_connected flag on reset, otherwise
# same as shutdown
yield [(o.typeclass, o.at_server_shutdown())
for o in ObjectDB.get_all_cached_instances()]
yield [(p.typeclass, p.at_server_shutdown())
for p in PlayerDB.get_all_cached_instances()]
yield [o.at_server_shutdown() for o in ObjectDB.get_all_cached_instances()]
yield [p.at_server_shutdown() for p in PlayerDB.get_all_cached_instances()]
else: # shutdown
yield [_SA(p, "is_connected", False)
for p in PlayerDB.get_all_cached_instances()]
yield [(o.typeclass, o.at_server_shutdown())
for o in ObjectDB.get_all_cached_instances()]
yield [(p.typeclass, p.unpuppet_all(), p.at_server_shutdown())
yield [_SA(p, "is_connected", False) for p in PlayerDB.get_all_cached_instances()]
yield [o.at_server_shutdown() for o in ObjectDB.get_all_cached_instances()]
yield [(p.unpuppet_all(), p.at_server_shutdown())
for p in PlayerDB.get_all_cached_instances()]
yield [(s.typeclass, s.at_server_shutdown())
for s in ScriptDB.get_all_cached_instances()]
yield [s.at_server_shutdown() for s in ScriptDB.get_all_cached_instances()]
yield ObjectDB.objects.clear_all_sessids()
ServerConfig.objects.conf("server_restart_mode", "reset")

View file

@ -266,7 +266,6 @@ class SharedMemoryModel(Model):
def get_all_cached_instances(cls):
"return the objects so far cached by idmapper for this class."
return cls.__instance_cache__.values()
#get_all_cached_instances = classmethod(get_all_cached_instances)
@classmethod
def _flush_cached_by_key(cls, key, force=True):
@ -276,7 +275,6 @@ class SharedMemoryModel(Model):
del cls.__instance_cache__[key]
except KeyError:
pass
#_flush_cached_by_key = classmethod(_flush_cached_by_key)
@classmethod
def flush_cached_instance(cls, instance, force=True):