[Dbix-class] Setup relationship for 'modified preorder tree traversal' structure

Charlie Garrison garrison at zeta.org.au
Tue Jun 26 09:25:57 GMT 2007


Good evening,

On 25/6/07 at 8:11 PM +0100, Matt S Trout 
<dbix-class at trout.me.uk> wrote:

>Not handled yet. Try
>
>sub descendants {
>my $self = shift;
>$self->result_source->resultset->search({
>'lft' => { -between => [ $self->lft, $self->rgt ] }
>});
>}

Thanks for the code; that was effectively what I was already 
doing in the controller. I've made a method for it per your 
suggestion above. I'm starting to get the hang of chaining 
resultsets too, and I'm really liking it.  :-)

>for the moment.
>
>If you'd be interested, I'd dearly love to see a nested set implementation
>for DBIx::Class::Tree and would be more than happy to help out if you get
>stuck anywhere in doing so.

I've got a lot of legacy (really messy) code for managing the 
nested-set tree I'm using. As I migrate that code I'll write in 
context of a DBIx::Class::Tree module. I'm sure you'll hear from 
me at the time.

Somehow I had missed DBIx::Class::Tree so thanks for the pointer 
to that. My nested-set tree also uses adjacency model for 
historical reasons. And I had already implemented a lot of what 
DBIC::Tree does. I'll just switch to that instead. (And add 
nested-set functionality as needed.)

>There's actually one already built into MojoMojo but the svn for that's
>currently midway through a migration - I'll reply again to this thread
>when that's done.

I've grabbed that and read through the code. It's already given 
me some ideas for how to improve my *pages* of legacy code for 
managing the tree structure.

Thanks again for your help.

Charlie

-- 
    Charlie Garrison  <garrison at zeta.org.au>
    PO Box 141, Windsor, NSW 2756, Australia

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
http://www.ietf.org/rfc/rfc1855.txt



More information about the Dbix-class mailing list