Created
March 14, 2012 18:18
-
-
Save andymccurdy/2038383 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat_to_remove = <category_publishable_is_being_removed_from> | |
categories = [all_current_leaf_categories_publishable_is_in]; | |
categories.remove(cat_to_remove); | |
all_cats = set() | |
for cat in categories: | |
while cat: | |
all_cats.add(cat) | |
cat = cat.parent | |
# all_cats should now be a set of all categories the publishable should still be in after the removal | |
while cat_to_remove: | |
if cat_to_remove in all_cats: | |
continue | |
remove(pub.id, cat_to_remove) | |
cat_to_remove = cat_to_remove.parent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment