From 65dcf305794feffb1da33c15b5af8d4964580d72 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 19 Nov 2008 02:21:37 +0000 Subject: - Fix ModelGraphTraverser; don't try to change the ``__name__`` or ``__parent__`` of an object that claims it implements ILocation during traversal even if the ``__name__`` or ``__parent__`` of the object traversed does not match the name used in the traversal step or the or the traversal parent . Rationale: it was insane to do so. This bug was only found due to a misconfiguration in an application that mistakenly had intermediate persistent non-ILocation objects; traversal was causing a persistent write on every request under this setup. - ``repoze.bfg.location.locate`` now unconditionally sets ``__name__`` and ``__parent__`` on objects which provide ILocation (it previously only set them conditionally if they didn't match attributes already present on the object via equality). Prep for 0.5.0. --- repoze/bfg/traversal.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'repoze/bfg/traversal.py') diff --git a/repoze/bfg/traversal.py b/repoze/bfg/traversal.py index 8c2df6a41..f6a415b85 100644 --- a/repoze/bfg/traversal.py +++ b/repoze/bfg/traversal.py @@ -3,7 +3,7 @@ import urlparse from zope.interface import classProvides from zope.interface import implements -from repoze.bfg.location import locate +from repoze.bfg.location import LocationProxy from repoze.bfg.location import lineage from repoze.bfg.interfaces import ILocation @@ -48,9 +48,8 @@ class ModelGraphTraverser(object): def __call__(self, environ): path = environ.get('PATH_INFO', '/') path = split_path(path) - root = self.root - ob = self.root + name = '' while path: @@ -59,8 +58,8 @@ class ModelGraphTraverser(object): if next is _marker: name = segment break - if self.locatable: - next = locate(next, ob, segment) + if (self.locatable) and (not ILocation.providedBy(next)): + next = LocationProxy(next, ob, segment) ob = next return ob, name, path -- cgit v1.2.3