From: Ian B. <ia...@co...> - 2004-11-29 16:07:37
|
Oleg Broytmann wrote: > Method SQLObject.set(), lines 769-774: > > if self._SO_creating or self._lazyUpdate: > for name, value in kw.items(): > fromPy = getattr(self, '_SO_fromPython_%s' % name, None) > if fromPy: > kw[name] = value = fromPy(value, self._SO_validatorState) > setattr(self, instanceName(name), value) > > Method SQLObject.set(), lines 793-801: > > for name, value in kw.items(): > fromPython = getattr(self, '_SO_fromPython_%s' % name, None) > if fromPython: > dbValue = fromPython(value, self._SO_validatorState) > else: > dbValue = value > toUpdate[name] = dbValue > if self._cacheValues: > setattr(self, instanceName(name), value) > > In the first snippet the value is converted from Python to db value and > assigned to the attribute named "name". In te second snippet in is not > converted; instead, new variable dbValue holds convertd value, and the > attribute "name" receives original, "pythonic" value. > Isn't there a bug in the first snippet? Shouldn't it be > > kw[name] = dbValue = fromPy(value, self._SO_validatorState) > setattr(self, instanceName(name), value) > > ? I am not sure how special _SO_creating is... Yes, you are correct. _SO_creating doesn't really matter one way or the other here. I've committed the fix you propose. -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |