summaryrefslogtreecommitdiff
path: root/repoze/bfg/location.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2008-11-19 02:21:37 +0000
committerChris McDonough <chrism@agendaless.com>2008-11-19 02:21:37 +0000
commit65dcf305794feffb1da33c15b5af8d4964580d72 (patch)
tree0ebad53fed1b951458aabda0741e71bcaeb4a17d /repoze/bfg/location.py
parent5483348a58f8c3adcc2dec7b2e6b188a588c04cf (diff)
downloadpyramid-65dcf305794feffb1da33c15b5af8d4964580d72.tar.gz
pyramid-65dcf305794feffb1da33c15b5af8d4964580d72.tar.bz2
pyramid-65dcf305794feffb1da33c15b5af8d4964580d72.zip
- 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.
Diffstat (limited to 'repoze/bfg/location.py')
-rw-r--r--repoze/bfg/location.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/repoze/bfg/location.py b/repoze/bfg/location.py
index 11f08faf9..ed7d2ad1f 100644
--- a/repoze/bfg/location.py
+++ b/repoze/bfg/location.py
@@ -39,10 +39,10 @@ def inside(model1, model2):
def locate(model, parent, name=None):
"""
If ``model`` explicitly provides the
- ``repoze.bfg.interfaces.ILocation`` interface, locate ``model``
- directly set ``model`` 's ``__parent__`` attribute to the
- ``parent`` object (also a model), and its ``__name__`` to the
- supplied ``name`` argument.
+ ``repoze.bfg.interfaces.ILocation`` interface, directly set
+ ``model`` 's ``__parent__`` attribute to the ``parent`` object
+ (also a model), and its ``__name__`` to the supplied ``name``
+ argument, and return the model.
If ``model`` does *not* explicitly provide the
``repoze.bfg.interfaces.ILocation`` interface, return a
@@ -53,8 +53,8 @@ def locate(model, parent, name=None):
instances.
"""
if ILocation.providedBy(model):
- if parent is not model.__parent__ or name != model.__name__:
- _locate(model, parent, name)
+ model.__parent__ = parent
+ model.__name__ = name
return model
return LocationProxy(model, parent, name)
@@ -83,10 +83,6 @@ def lineage(model):
yield model
model = getattr(model, '__parent__', None)
-def _locate(model, parent, name=None):
- model.__parent__ = parent
- model.__name__ = name
-
class ClassAndInstanceDescr(object):
def __init__(self, *args):