Added catch to NavigationManager.get_for_node for cases where items do not have a...
authorStephen Burrows <stephen.r.burrows@gmail.com>
Fri, 24 Jun 2011 19:21:27 +0000 (15:21 -0400)
committerStephen Burrows <stephen.r.burrows@gmail.com>
Fri, 24 Jun 2011 19:21:27 +0000 (15:21 -0400)
philo/contrib/shipherd/models.py

index 3655e51..95be501 100644 (file)
@@ -74,7 +74,8 @@ class NavigationManager(models.Manager):
                                by_pk[root.pk] = root
                                tree_ids.append(getattr(root, item_opts.tree_id_attr))
                                root._cached_children = []
                                by_pk[root.pk] = root
                                tree_ids.append(getattr(root, item_opts.tree_id_attr))
                                root._cached_children = []
-                               root.target_node.get_path(root=site_root_node)
+                               if root.target_node:
+                                       root.target_node.get_path(root=site_root_node)
                                root.navigation = nav
                        
                        kwargs = {
                                root.navigation = nav
                        
                        kwargs = {
@@ -89,7 +90,8 @@ class NavigationManager(models.Manager):
                                parent_pk = getattr(item, '%s_id' % item_opts.parent_attr)
                                item.parent = by_pk[parent_pk]
                                item.parent._cached_children.append(item)
                                parent_pk = getattr(item, '%s_id' % item_opts.parent_attr)
                                item.parent = by_pk[parent_pk]
                                item.parent._cached_children.append(item)
-                               item.target_node.get_path(root=site_root_node)
+                               if item.target_node:
+                                       item.target_node.get_path(root=site_root_node)
                        
                        cached = roots
                        cache.set(cache_key, cached)
                        
                        cached = roots
                        cache.set(cache_key, cached)