Traits : Any facility for "inverse" relations?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Traits : Any facility for "inverse" relations?

Des.P
Does traits have a facility to declare an inverse relation?

e.g.

class Parent(HasTraits):
        children = List('Child', inverse = 'parent')

class Child(HasTraits):
        parent = Instance(Parent)

Thanks!
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Traits : Any facility for "inverse" relations?

Adam Hughes
I await an answer as well, but may I ask if this is the type of functionality you're looking to supplant?

class Parent(HasTraits):
    children=List('Child')
    def have_kid(self):
         newkid=Child(parent=self)
         children.append(newkid)


On Mon, Oct 1, 2012 at 8:03 PM, Des.P <[hidden email]> wrote:
Does traits have a facility to declare an inverse relation?

e.g.

class Parent(HasTraits):
        children = List('Child', inverse = 'parent')

class Child(HasTraits):
        parent = Instance(Parent)

Thanks!
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Traits : Any facility for "inverse" relations?

Chris Colbert
In reply to this post by Des.P
No, you will have to establish such a relationship yourself.

On Mon, Oct 1, 2012 at 8:03 PM, Des.P <[hidden email]> wrote:
Does traits have a facility to declare an inverse relation?

e.g.

class Parent(HasTraits):
        children = List('Child', inverse = 'parent')

class Child(HasTraits):
        parent = Instance(Parent)

Thanks!
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Traits : Any facility for "inverse" relations?

Des.P
In reply to this post by Adam Hughes
Roughly, yes, although right now I am looking at just the data-model implied by the combination of traits. Thanks!

Desmond

On Oct 1, 2012, at 7:11 PM, Adam Hughes wrote:

I await an answer as well, but may I ask if this is the type of functionality you're looking to supplant?

class Parent(HasTraits):
    children=List('Child')
    def have_kid(self):
         newkid=Child(parent=self)
         children.append(newkid)


On Mon, Oct 1, 2012 at 8:03 PM, Des.P <[hidden email]> wrote:
Does traits have a facility to declare an inverse relation?

e.g.

class Parent(HasTraits):
        children = List('Child', inverse = 'parent')

class Child(HasTraits):
        parent = Instance(Parent)

Thanks!
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev