diff options
| author | Chris McDonough <chrism@agendaless.com> | 2008-08-08 23:27:38 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2008-08-08 23:27:38 +0000 |
| commit | 5edd5a45526b886a4a3f348262e6888757662bd5 (patch) | |
| tree | 246b91e4b213b67387ccbff8b79f10701f46b393 | |
| parent | cc5e490467c105b8cce35c0bca688ed18ec93255 (diff) | |
| download | pyramid-5edd5a45526b886a4a3f348262e6888757662bd5.tar.gz pyramid-5edd5a45526b886a4a3f348262e6888757662bd5.tar.bz2 pyramid-5edd5a45526b886a4a3f348262e6888757662bd5.zip | |
find_context_from_path -> find_model
| -rw-r--r-- | CHANGES.txt | 6 | ||||
| -rw-r--r-- | repoze/bfg/tests/test_traversal.py | 6 | ||||
| -rw-r--r-- | repoze/bfg/traversal.py | 13 |
3 files changed, 13 insertions, 12 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 84a27b021..809e0f885 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,8 +1,8 @@ After 0.2.7 - - Add ``find_context_from_path`` and ``find_root`` traversal APIs. - In the process, make ITraverser a uni-adapter (on context) rather - than a multiadapter (on context and request). + - Add ``find_model`` and ``find_root`` traversal APIs. In the + process, make ITraverser a uni-adapter (on context) rather than a + multiadapter (on context and request). 0.2.7 diff --git a/repoze/bfg/tests/test_traversal.py b/repoze/bfg/tests/test_traversal.py index 075cfe85e..a61a324e2 100644 --- a/repoze/bfg/tests/test_traversal.py +++ b/repoze/bfg/tests/test_traversal.py @@ -205,10 +205,10 @@ class FindRootTests(unittest.TestCase): result = find(baz) self.assertEqual(result, dummy) -class FindContextFromPathTests(unittest.TestCase): +class FindModelTests(unittest.TestCase): def _getFUT(self): - from repoze.bfg.traversal import find_context_from_path - return find_context_from_path + from repoze.bfg.traversal import find_model + return find_model def _registerTraverser(self, traverser): import zope.component diff --git a/repoze/bfg/traversal.py b/repoze/bfg/traversal.py index 3fe11f9f7..e307cae0c 100644 --- a/repoze/bfg/traversal.py +++ b/repoze/bfg/traversal.py @@ -74,7 +74,7 @@ def find_root(model): break return model -def find_context_from_path(model, path): +def find_model(model, path): """ Given a model object and a string representing a path reference (a set of names delimited by forward-slashes), return an context in this application's model graph at the specified path. @@ -94,11 +94,12 @@ def find_context_from_path(model, path): raise KeyError('%r has no subelement %s' % (ob, name)) return ob -def find_interface(context, interface): - """ Return an object providing ``interface`` anywhere in the - parent chain of ``context`` or ``None`` if no object providing - that interface can be found in the parent chain""" - for location in LocationIterator(context): +def find_interface(model, interface): + """ Return the first object found which provides the interface + ``interface`` in the parent chain of ``model`` or ``None`` if no + object providing ``interface`` can be found in the parent chain. + The ``model`` passed in should be :term:`location`-aware.""" + for location in LocationIterator(model): if interface.providedBy(location): return location |
