Site Sections: Satchmo Main | Wiki | Demo Store |

Ticket #202 (new enhancement)

Opened 2 years ago

Last modified 2 months ago

Use Modified Preorder Tree Traversal in Category

Reported by: hkpark Assigned to: chris
Priority: major Milestone:
Component: Application Version:
Keywords: product category mptt recursion Cc:

Description

I've added MPTT to the product category and removed the recursion. Although I did leave in the old private function names in case some people were using them on the sly.

Here's a link to an article about the pros and cons of it: == http://www.sitepoint.com/print/hierarchical-data-database == Storing Hierarchical Data in a Database

I thought Satchmo shouldn't go without some method of retrieving rows with a single query. I'm working with some larger category trees than the sample store data and thought this might speed things up since the category tree is frequently used.

Now getting children and getting parents is a single query, no recursing down the tree and building a large function stack and fetching the items one by one.

Attachments

models.patch.txt (3.4 kB) - added by hkpark on 11/01/2007 10:20:02 PM.
product/models.py patch for MPTT
product-models-mptt.diff (3.7 kB) - added by jshaffer on 11/02/2007 01:12:21 AM.
product-models-mptt-r3.diff (6.0 kB) - added by hkpark on 11/02/2007 05:11:44 AM.
r3 11/02/07 05:09:25 changes

Change History

11/01/2007 10:20:02 PM changed by hkpark

  • attachment models.patch.txt added.

product/models.py patch for MPTT

11/01/2007 10:20:52 PM changed by hkpark

  • type changed from defect to enhancement.

sorry, changing to enhancement

11/02/2007 01:12:21 AM changed by jshaffer

  • attachment product-models-mptt.diff added.

11/02/2007 01:17:06 AM changed by jshaffer

  • summary changed from Added Modified Preorder Tree Traversal to Product Category. Removed recursion to Use Modified Preorder Tree Traversal in Category.
  • milestone set to 0.7.

I've attached a diff with some changes that were necessary to get it to run. However, I'm seeing regressions in the tests. Would you verify that the tests pass and update them as needed?

11/02/2007 01:29:00 AM changed by hkpark

left and right are keywords in SQL, so you can't use them for field names, hence the lft and rght. Maybe there should be a comment in there explaining that.

I'll take a look at changes besides those and see how to run these tests.

Harry

11/02/2007 05:09:25 AM changed by hkpark

Okay I've updated the changes again. I noticed some errors in my initial version. It would only allow for one root in all the categories, but the demo store has 3 separate root categories: Books, Shirts, Software. So I've updated the class to allow for multiple roots. The data is correct in the admin for the demo store. It wasn't in the first iteration.

Included comments about the purposely misspelled left and right: lft, rght

Also noticed that the test cases assume that you will be able to create an infinite loop with the Category class. The class with this patch won't let you make an infinite loop because it will immediately reorder the tree on save. The subsequent tests fail because they need the infinite loop to be in the database.

I can add some more tests to tests.py that just give more straightforward category structures and makes sure the data comes back correct. My thoughts were to add multiple root categories like in the demo store, make sure the parents are correct, the children come back correct. I've spent one day with the class so I was hoping to work with someone to ensure I'm testing for the right data.

11/02/2007 05:11:44 AM changed by hkpark

  • attachment product-models-mptt-r3.diff added.

r3 11/02/07 05:09:25 changes

11/02/2007 04:46:39 PM changed by chris

Do we also need to look at modifying the satchmo_category.py template tag to not recurse?

11/02/2007 06:32:25 PM changed by hkpark

I'm looking at updating that now.

11/09/2007 03:19:35 AM changed by chris

I found this project which has some code that might be useful - http://code.google.com/p/django-categories/

12/29/2007 07:42:19 PM changed by chris

Another implementation - http://code.google.com/p/django-mptt/

03/22/2008 03:16:57 PM changed by chris

  • milestone deleted.

I'm moving out of the next release. This might be useful but it's not a requirement at this time.

05/30/2008 05:42:29 PM changed by airforce1

08/12/2008 02:49:18 PM changed by add

http://www.salewroughtiron.cn installing metal stair rails Interior stair handrail installing metal stair rails Interior stair handrail exterior baluster Glass wood stainless wrought CONTEMPORARY designs stairways aluminum modern log banister DECK outdoor price posts vinyl curved rails http://www.china-made-door.com.cn door gate http://www.beijing-door.cn wrought CONTEMPORARY designs stairways installing metal stair rails Interior stair handrail exterior baluster Glass wood stainless wrought CONTEMPORARY designs stairways aluminum modern log banister DECK outdoor price posts vinyl curved rails http://www.hebei-railings.cn aluminum modern log banister DECK outdoor price installing metal stair rails Interior stair handrail exterior baluster Glass wood stainless wrought CONTEMPORARY designs stairways aluminum modern log banister DECK outdoor price posts vinyl curved rails posts vinyl curved rails

09/12/2008 06:30:43 AM changed by china

china tour Apparel shoes bags Kitchen Food and Wine Furniture) Flowers and Gifts Wall Art Computer Components

I still prefer a wiki like approach since the php (or mysql) docs are very cluttered when you have to take their comments in account. On the other hand they are professionally maintained imho, since they are *much* better than KDE documentation. KDE is by far larger and has so many different apps, which need screenshots and end user not dev/api docs, that more help is needed as long as the devs prefer to code than to write nice docs. And it is their choice to some degree imo. Technically interested but non-dev end users, which are plenty out there, are the users of and the best contributers to the docs, since they know what to write about. And they are certainly more than devs

12/26/2008 03:56:06 AM changed by solar

Changzhou Sunpower Solar Water Heater Co., Ltd is a private company, professional producing solar water heater, and having the most advanced production line in Chinese, like automatic foaming machine imported from Italy, automatic argon arc welding machine from America, and numerical control punch. We use Germany Bayer's polyurethane and SUS304 stainless steel from Korea and Taiwan. Our company is one of the earliest companies engaging in exporting, having many years experience in exporting, and 90% of our products are exported to overseas market.

Sunpower Solar Energy Industry Co., Ltd, covers an area of nearly 150000 square metre, Now it has more than 300 workers and staff members among which the primary. Medium and high grade technicians share 65% of the total personnel. It is of abumdant technical force, advanced craft testing means. Its annual productive capacity reaches to 300000 sets. Our factory is the first to pass the ISO9001: 2000 quality system attestation among the same trade. Our products have get EN12975: 2 certificate, and all of the products are strictly complied with its standard. The goods reach to the first-class international standard. Now already export 62 counties. Our gain is "Where is sunlight, where is Sunpower". OEM also welcome.

http://www.solar-water-heaters.com.cn

03/18/2009 02:41:15 AM changed by sneakeralley

04/30/2009 10:04:59 AM changed by jamieee

04/30/2009 10:05:45 AM changed by jamieee