From 5b38f27554e1693af73dece323236b68ef9e07ea Mon Sep 17 00:00:00 2001 From: Griatch Date: Tue, 30 Sep 2014 14:12:58 +0200 Subject: [PATCH] Made property assignment go to Typeclass if that property were already defined on typeclass; otherwise relegate to dbobj as before. This fixes issues with property assignments on the Typeclass level. There are no obvious regressions in testing this but it's something to keep an eye out for in case there are any unexpected side effects. --- src/commands/command.py | 9 ++++----- src/typeclasses/typeclass.py | 24 ++++++++++++++---------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/commands/command.py b/src/commands/command.py index 9ab18aa241..04bd773283 100644 --- a/src/commands/command.py +++ b/src/commands/command.py @@ -242,13 +242,12 @@ class Command(object): if hasattr(to_obj, "sessid"): # this is the case when to_obj is e.g. a Character toobj_sessions = to_obj.sessid.get() - + # If to_obj has more than one session MULTISESSION_MODE=3 - # we need to send to every session. + # we need to send to every session. #(setting it to None, does it) - if len(toobj_sessions)>1: - session_tosend=None - else: + session_tosend = None + if len(toobj_sessions) == 1: session_tosend=toobj_sessions[0] sessid = all_sessions and None or session_tosend elif to_obj == self.caller: diff --git a/src/typeclasses/typeclass.py b/src/typeclasses/typeclass.py index 3920cbe422..a8fe2a02db 100644 --- a/src/typeclasses/typeclass.py +++ b/src/typeclasses/typeclass.py @@ -119,8 +119,9 @@ class TypeClass(object): def __setattr__(self, propname, value): """ - Transparently save data to the dbobj object in - all situations. Note that this does not + Transparently save data. Use property on Typeclass only if + that property is already defined, otherwise relegate to the + dbobj object in all situations. Note that this does not necessarily mean storing it to the database. """ #print "set %s -> %s" % (propname, value) @@ -130,15 +131,18 @@ class TypeClass(object): log_errmsg(string % (self.name, propname)) return try: - dbobj = _GA(self, 'dbobj') - except AttributeError: - dbobj = None - log_trace("This is probably due to an unsafe reload.") - if dbobj: - _SA(dbobj, propname, value) - else: - # only as a last resort do we save on the typeclass object + _GA(self, propname) _SA(self, propname, value) + except AttributeError: + try: + dbobj = _GA(self, 'dbobj') + except AttributeError: + dbobj = None + if dbobj: + _SA(dbobj, propname, value) + else: + # only as a last resort do we save on the typeclass object + _SA(self, propname, value) def __eq__(self, other): """