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

@ -246,9 +246,8 @@ class Command(object):
# 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)
@ -129,11 +130,14 @@ class TypeClass(object):
string += " (protected: [%s])" % (", ".join(PROTECTED)) string += " (protected: [%s])" % (", ".join(PROTECTED))
log_errmsg(string % (self.name, propname)) log_errmsg(string % (self.name, propname))
return return
try:
_GA(self, propname)
_SA(self, propname, value)
except AttributeError:
try: try:
dbobj = _GA(self, 'dbobj') dbobj = _GA(self, 'dbobj')
except AttributeError: except AttributeError:
dbobj = None dbobj = None
log_trace("This is probably due to an unsafe reload.")
if dbobj: if dbobj:
_SA(dbobj, propname, value) _SA(dbobj, propname, value)
else: else: