From: Stephen Burrows Date: Fri, 24 Jun 2011 17:09:33 +0000 (-0400) Subject: Generalized the 'single step' case in TreeEntity.get_path to include the case where... X-Git-Tag: philo-0.9.1^2~7^2^2~2 X-Git-Url: http://git.ithinksw.org/philo.git/commitdiff_plain/13aa22003d4b88fff35a631f270bd11a156de71a Generalized the 'single step' case in TreeEntity.get_path to include the case where the root is the direct parent of the current instance. --- diff --git a/philo/models/base.py b/philo/models/base.py index 2138381..8df67c3 100644 --- a/philo/models/base.py +++ b/philo/models/base.py @@ -471,14 +471,15 @@ class TreeEntity(Entity, MPTTModel): if root == self: return '' - if root is None and self.is_root_node(): + parent_id = getattr(self, "%s_id" % self._mptt_meta.parent_attr) + if getattr(root, 'pk', None) == parent_id: return getattr(self, field, '?') if root is not None and not self.is_descendant_of(root): raise AncestorDoesNotExist(root) if memoize: - memo_args = (getattr(self, "%s_id" % self._mptt_meta.parent_attr), getattr(root, 'pk', None), pathsep, getattr(self, field, '?')) + memo_args = (parent_id, getattr(root, 'pk', None), pathsep, getattr(self, field, '?')) try: return self._path_memo[memo_args] except AttributeError: