Skip to content

Commit

Permalink
Split functionality, since not all request types use the concept of
Browse files Browse the repository at this point in the history
views.
  • Loading branch information
strichter committed Dec 9, 2007
1 parent cc1f619 commit 6c5935f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
16 changes: 12 additions & 4 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@
CHANGES
=======

0.2.2 (2007-12-??)
------------------

- Restructuring: Separated pluggable traverser functionality into two classes
for better code reuse.


0.2.1 (2007-11-92)
------------------

- bugfix: if viewlet and managers get nested a viewlet was not found if
- Bugfix: if viewlet and managers get nested a viewlet was not found if
the depth reaches 3 because the context was set to the page and not
to the context object
- bugfix: replaced call to _getContextName because it has been removed from
absoluteURL
to the context object.

- Bugfix: replaced call to ``_getContextName`` because it has been removed
from ``absoluteURL``.


0.2.0 (2007-10-31)
Expand Down
22 changes: 17 additions & 5 deletions src/z3c/traverser/traverser.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,38 @@

_marker = object()

class PluggableTraverser(object):
"""Generic Pluggable Traverser."""

class BasePluggableTraverser(object):
implements(interfaces.IPluggableTraverser)

def __init__(self, context, request):
self.context = context
self.request = request

def publishTraverse(self, request, name):
# 1. Look at all the traverser plugins, whether they have an answer.
# Look at all the traverser plugins, whether they have an answer.
for traverser in subscribers((self.context, request),
interfaces.ITraverserPlugin):
try:
return traverser.publishTraverse(request, name)
except NotFound:
pass

# 2. The traversers did not have an answer, so let's see whether it is
# a view.
raise NotFound(self.context, name, request)


class PluggableTraverser(BasePluggableTraverser):
"""Generic Pluggable Traverser."""

def publishTraverse(self, request, name):
try:
return super(PluggableTraverser, self).publishTraverse(
request, name)
except NotFound:
pass

# The traversers did not have an answer, so let's see whether it is a
# view.
view = queryMultiAdapter((self.context, request), name=name)
if view is not None:
return view
Expand Down

0 comments on commit 6c5935f

Please sign in to comment.