From: nkeric <nke...@gmail.com>
Date: Thu, 27 Jul 2006 12:05:28 +0800
Local: Thurs, Jul 27 2006 12:05 am
Subject: generic ModifiedPreorderTreeTraversal app
Base upon Julio's mptt-0.9 which handles nested contents: http://code.djangoproject.com/wiki/ModifiedPreorderTreeTraversal I made this more "generic" version mptt-0.95, from the README: [snip] Follow up by me =============== First of all, ***BIG Thanks*** to `Gijs Van Tulder's excellent Julio's GREAT work on this django implementation! mptt-0.95 (following django's svn version number:) based on Julio's "generic": - Julio's version treats the root content (for example, an Article commented/follow-up'd) & the tree of the root content differently), response for both "describing a tree" & "storing node content". - In this modified version, I "limit" the Node model's responsibility tree": you keep storing your model's data in a "flat" way, once them into a "tree", and, ***you can organize this tree across all of that means, you can build your tree with User, Article, Group, as the tree's node:) While comparing the code between Julio's original version and my Both versions are using the GenericForeignKey_ like technique, and object_id fields, however, they are different: - Julio's version uses these fields to refer to the ***root content - This modified version uses them to refer to ***content object that Please check the code for detail:) Sample code ----------- from path.to.your.models import Article from agv.apps.mptt.models import Node a1 = Article.objects.get(pk=1) a2 = Article.objects.get(pk=2) a3 = Article.objects.get(pk=3) a4 = Article.objects.get(pk=4) a5 = Article.objects.get(pk=5) n1 = Node(content_object=a1) # the root node n1.save() # 2nd level nodes n2 = Node(content_object=a2, parent=a1) n2.save() n3 = Node(content_object=a3, parent=a1) n3.save() # 3rd level nodes n4 = Node(content_object=a4, parent=a2) n4.save() n5 = Node(content_object=a5, parent=a3) n5.save() # you can even do this from path.to.your.other.models import Banana b = Banana.objects.get(pk=1) # add the banana to the tree of articles! :-p n6 = Node(content_object=b, parent=a1) n6.save() Thanks again to Julio's code! Please help me to test it if you're interested:) Sorry for my poor English! With any problem, find me at: Eric Hsu nke...@gmail.com .. _Gijs Van Tulder's excellent article: .. _GenericForeignKey: --
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| |||||||||||||||||
From: Cheng Zhang <czhang....@gmail.com>
Date: Thu, 27 Jul 2006 12:25:48 +0800
Local: Thurs, Jul 27 2006 12:25 am
Subject: Re: generic ModifiedPreorderTreeTraversal app
Great.
If you get time, I suggest you update the wiki page accordingly. - Cheng Zhang On Jul 27, 2006, at 12:05 PM, nkeric wrote: You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||
From: "nkeric" <nke...@gmail.com>
Date: Thu, 27 Jul 2006 09:16:21 -0000
Local: Thurs, Jul 27 2006 5:16 am
Subject: Re: generic ModifiedPreorderTreeTraversal app
Cheng Zhang wrote: ok, I'll do that soon. > Great. > If you get time, I suggest you update the wiki page accordingly. plus, a bug fix to the views.py in the node_tree method, the node_list line should add an node_list = Node.objects.filter(tree_id__exact=root.tree_id, otherwise the tree doesn't diplay correctly :p You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||
| Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy |
| ©2009 Google |