Re: help understanding mptt/treebeard

2011-02-04 Thread Tim
Hi Jason,
Thanks for explaining. I suppose I was trying to make my problem
harder than it really is.

My answer for the problem of a user who wants to remove or insert a
chapter is to use a field called 'sequence_number'.

If a user deletes or adds a chapter, I have a pre-save function that
(1) loops over all the chapters in the current book that have a
sequence_number > the one the user entered (or >= if adding),
(2) increment or decrement the value for each chapter,
(3) save them, and then
(4) call save on the current chapter.

Is that the best way to handle the situation?
thanks again for your input,
--Tim Arnold

On Feb 3, 12:08 pm, Jason  wrote:
> "maybe a chapter needs to be added as the
> 13th chapter in a Book, for example"
>
> MPTT and the other trees are mainly used on data structures where node
> insertion might happen anywhere on a tree.
> In your case, you only put chapters in books and would never move a
> chapter inside of a 'Library' or inside a 'File'.
>
> In other words these trees are all made up of the same node type - the
> typical example would be a 'Category'.
> Categories can have subcategories, which have sub-subcategories, etc.
>
> I'm not an expert but to me it doesn't look like you'd get much gain
> from using MPTT in this situation.
>
> On Feb 3, 7:58 am, Tim  wrote:
>
>
>
>
>
>
>
> > hi,
> > I think mptt or treebeard may be a good fit for my project, but I'm
> > not sure. Currently I have the project setup in a conventional way
> > with no explicit tree structure, just a pattern of ForeignKey usage.
> > It works, but I'm beginning to get into some complexity.
>
> > The project is for building (compiling) a large set of documentation.
> > A 'Library' contains 'Books'; A 'Book' contains 'Chapters';' Chapters'
> > are made up of 'Files' and 'Files' refer to external 'Images'. Each of
> > these elements has its own set of configuration parameters.
>
> > I'm trying to write an interface for writers to configure 'Books' and/
> > or 'Chapters', which could mean setting particular configuration
> > fields for the element, or removing/adding elements into the overall
> > hierarchy at specific points (maybe a chapter needs to be added as the
> > 13th chapter in a Book, for example).
>
> > I have the merest grasp of tree traversal and the associated
> > mathematics, but from reading the mptt docs, I think that the
> > application might be the perfect fit for my project.
>
> > Can someone confirm or point me to some other documentation to help me
> > figure this out?
> > thanks,
> > --Tim Arnold

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: help understanding mptt/treebeard

2011-02-03 Thread Jason
"maybe a chapter needs to be added as the
13th chapter in a Book, for example"

MPTT and the other trees are mainly used on data structures where node
insertion might happen anywhere on a tree.
In your case, you only put chapters in books and would never move a
chapter inside of a 'Library' or inside a 'File'.

In other words these trees are all made up of the same node type - the
typical example would be a 'Category'.
Categories can have subcategories, which have sub-subcategories, etc.

I'm not an expert but to me it doesn't look like you'd get much gain
from using MPTT in this situation.


On Feb 3, 7:58 am, Tim  wrote:
> hi,
> I think mptt or treebeard may be a good fit for my project, but I'm
> not sure. Currently I have the project setup in a conventional way
> with no explicit tree structure, just a pattern of ForeignKey usage.
> It works, but I'm beginning to get into some complexity.
>
> The project is for building (compiling) a large set of documentation.
> A 'Library' contains 'Books'; A 'Book' contains 'Chapters';' Chapters'
> are made up of 'Files' and 'Files' refer to external 'Images'. Each of
> these elements has its own set of configuration parameters.
>
> I'm trying to write an interface for writers to configure 'Books' and/
> or 'Chapters', which could mean setting particular configuration
> fields for the element, or removing/adding elements into the overall
> hierarchy at specific points (maybe a chapter needs to be added as the
> 13th chapter in a Book, for example).
>
> I have the merest grasp of tree traversal and the associated
> mathematics, but from reading the mptt docs, I think that the
> application might be the perfect fit for my project.
>
> Can someone confirm or point me to some other documentation to help me
> figure this out?
> thanks,
> --Tim Arnold

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



help understanding mptt/treebeard

2011-02-03 Thread Tim
hi,
I think mptt or treebeard may be a good fit for my project, but I'm
not sure. Currently I have the project setup in a conventional way
with no explicit tree structure, just a pattern of ForeignKey usage.
It works, but I'm beginning to get into some complexity.

The project is for building (compiling) a large set of documentation.
A 'Library' contains 'Books'; A 'Book' contains 'Chapters';' Chapters'
are made up of 'Files' and 'Files' refer to external 'Images'. Each of
these elements has its own set of configuration parameters.

I'm trying to write an interface for writers to configure 'Books' and/
or 'Chapters', which could mean setting particular configuration
fields for the element, or removing/adding elements into the overall
hierarchy at specific points (maybe a chapter needs to be added as the
13th chapter in a Book, for example).

I have the merest grasp of tree traversal and the associated
mathematics, but from reading the mptt docs, I think that the
application might be the perfect fit for my project.

Can someone confirm or point me to some other documentation to help me
figure this out?
thanks,
--Tim Arnold

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.