On Tue, 14 Nov 2006 04:48:56 -0000 "kerinin" <[EMAIL PROTECTED]> wrote:
> > I have a class with two properties, and I only want to allow one of > the properties to be set at a time. Each time a property is set, it > checks to see if the other one is defined and deletes it if it is. > Here's my code: > > --------------------------------- > class class1(SQLObject): > prop_1 = StringCol(default='') > prop_2 = StringCol(default='') > > def _set_prop_1(self,value): > self._SO_set_prop_1(value) > if self.prop_2: > self.prop_2 = None > def _set_prop_2(self,value): > self._SO_set_prop_2(value) > if self.prop_1: > self.prop_1 = None > -------------------------------- > > and here's the error it gives me: > > -------------------------------- > >>> c=class1() > Traceback (most recent call last): > File "<console>", line 1, in ? > File > "/usr/lib/python2.4/site-packages/SQLObject-0.7.2b1-py2.4.egg/sqlobject/declarative.py", > line 93, in _wrapper > return fn(self, *args, **kwargs) > File > "/usr/lib/python2.4/site-packages/SQLObject-0.7.2b1-py2.4.egg/sqlobject/main.py", > line 1203, in __init__ > self._create(id, **kw) > File > "/usr/lib/python2.4/site-packages/SQLObject-0.7.2b1-py2.4.egg/sqlobject/main.py", > line 1227, in _create > self.set(**kw) > File > "/usr/lib/python2.4/site-packages/SQLObject-0.7.2b1-py2.4.egg/sqlobject/main.py", > line 1105, in set > raise AttributeError, '%s (with attribute %r)' % (e, name) > AttributeError: 'class1' object has no attribute 'id' (with attribute > 'prop_1') > >>> > ---------------------------------- > > Any ideas how to fix this? This is just a guess, but try using _SO_get_prop_1() instead of self.prop_1. Jason
signature.asc
Description: PGP signature

