On Mon, Jun 11, 2007 at 04:24:11PM -0400, Stanko Petrovic wrote:
> class Testadd(so.SQLObject):
> class sqlmeta:
> style = so.MixedCaseStyle(longID=True)
> table = 'testadd'
>
> Name = so.StringCol()
> BufferSize = so.FloatCol( default = 0.0 )
>
> def _set_BufferSize(self, value):
> if value != self._SO_get_BufferSize():
> value = 1.0
> self._SO_set_BufferSize(value)
>
> def _get_BufferSize(self):
> return self._SO_get_BufferSize()
>
> t2=Testadd(Name="test6")
You are creating a new row; the row hasn't been instered yet, so it
doesn't have an id. But before setting the new value in _set_BufferSize()
you ask the database about the previous value. How can SQLObject answer the
question without knowing the id of the row? It cannot, hence the error:
> This fails with error main.py line 1124 in set
> raise AttributeError ......
> Testadd object has no attribute 'id' (with attribute 'BufferSize')
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ phd@...
Programmers don't die, they just GOSUB without RETURN.
|