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?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---