On 11/14/06, kerinin <[EMAIL PROTECTED]> wrote:
> OK, here's what i tried (the class is a little different - it's the
> actual class i'm working on)

So I decided to read the docs, as I haven't done SO in 9 months.

First, you shouldn't be overriding __init__, sorry for that
misdirection. Second, I actually wrote the code and thought about it a
bit more.

It turns out that the problem is simply that the test for the _set_ is
happening before the other attribute comes into existence. Sorry about
sending you down the wrong path.

You had a few other problems, '' evaluates to False and not None so
you can wind up with both having '', which seems to be not what you
intended. Also doing self.otherValue = None will set both to None.

Here's a working version of your test class:

class class1(SQLObject):
    prop_1 = StringCol(default='')
    prop_2 = StringCol(default='')

    def _set_prop_1(self, value):
        self._SO_set_prop_1(value)
        if hasattr(self,'prop_2') and self.prop_2 is not None:
            self._SO_set_prop_2(None)

    def _set_prop_2(self, value):
        self._SO_set_prop_2(value)
        if hasattr(self,'prop_1') and self.prop_1 is not None:
            self._SO_set_prop_1(None)

And the output:
In [1]: x = class1()

In [2]: x
Out[2]: <class1 1 prop_1=None prop_2=''>

In [3]: x.prop_1 = '2'

In [4]: x
Out[4]: <class1 1 prop_1='2' prop_2=None>

--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to