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.

This commit is contained in:
Griatch 2014-09-30 14:12:58 +02:00
parent 348ff0b5f4
commit 5b38f27554
2 changed files with 18 additions and 15 deletions

View file

@ -242,13 +242,12 @@ class Command(object):
if hasattr(to_obj, "sessid"): if hasattr(to_obj, "sessid"):
# this is the case when to_obj is e.g. a Character # this is the case when to_obj is e.g. a Character
toobj_sessions = to_obj.sessid.get() toobj_sessions = to_obj.sessid.get()
# If to_obj has more than one session MULTISESSION_MODE=3 # 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) #(setting it to None, does it)
if len(toobj_sessions)>1: session_tosend = None
session_tosend=None if len(toobj_sessions) == 1:
else:
session_tosend=toobj_sessions[0] session_tosend=toobj_sessions[0]
sessid = all_sessions and None or session_tosend sessid = all_sessions and None or session_tosend
elif to_obj == self.caller: elif to_obj == self.caller:

View file

@ -119,8 +119,9 @@ class TypeClass(object):
def __setattr__(self, propname, value): def __setattr__(self, propname, value):
""" """
Transparently save data to the dbobj object in Transparently save data. Use property on Typeclass only if
all situations. Note that this does not 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. necessarily mean storing it to the database.
""" """
#print "set %s -> %s" % (propname, value) #print "set %s -> %s" % (propname, value)
@ -130,15 +131,18 @@ class TypeClass(object):
log_errmsg(string % (self.name, propname)) log_errmsg(string % (self.name, propname))
return return
try: try:
dbobj = _GA(self, 'dbobj') _GA(self, propname)
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
_SA(self, propname, value) _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): def __eq__(self, other):
""" """