Skip to content

Commit

Permalink
- Feature: Added ability to register a Null-adapter as a breadcrumb. A
Browse files Browse the repository at this point in the history
  null-breadcrumb will cause the item not to be displayed in the breadcrumbs.

- Get ready for release.
  • Loading branch information
strichter committed May 29, 2009
1 parent bca26d9 commit d943554
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
6 changes: 4 additions & 2 deletions CHANGES.txt
Expand Up @@ -2,9 +2,11 @@
CHANGES
=======

1.0.4 (unreleased)
1.1.0 (2009-05-29)
------------------

- ...
- Feature: Added ability to register a Null-adapter as a breadcrumb. A
null-breadcrumb will cause the item not to be displayed in the breadcrumbs.

1.0.3 (2008-12-13)
------------------
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -23,7 +23,7 @@ def read(*rnames):

setup (
name='z3c.breadcrumb',
version='1.0.4dev',
version='1.1.0',
author = "Roger Ineichen,Stephan Richter and the Zope Community",
author_email = "zope3-dev@zope.org",
description = "A pluggable breadcrumbs implementation based on adapters.",
Expand Down
25 changes: 20 additions & 5 deletions src/z3c/breadcrumb/README.txt
Expand Up @@ -137,22 +137,37 @@ Now we can collect breadcrumbs for our items. You can see the url is correct
and the label ``Zope Foundation`` is collected by the custom IBreadcrumb
adapter:

>>> breadcrumb = zope.component.getMultiAdapter((office, request),
>>> breadcrumbs = zope.component.getMultiAdapter((office, request),
... interfaces.IBreadcrumbs)
>>> list(breadcrumb.crumbs)
>>> list(breadcrumbs.crumbs)
[{'url': 'http://127.0.0.1',
'activeURL': True,
'name': 'top'},
{'url': 'http://127.0.0.1/office',
'activeURL': True,
'name': u'Zope Foundation'}]

>>> breadcrumb.__parent__ is office
>>> breadcrumbs.__parent__ is office
True

Default breadcrumbs stops on virtual host root

>>> request._vh_root = office
>>> list(breadcrumb.crumbs)
>>> list(breadcrumbs.crumbs)
[{'url': 'http://127.0.0.1', 'activeURL': True, 'name': u'Zope Foundation'}]

If the breadcrumb of an item is a Null-adapter, then the item is ignored.

>>> from zope.traversing.interfaces import IContainmentRoot
>>> zope.component.provideAdapter(
... lambda c, r: None,
... (IContainmentRoot, IHTTPRequest),
... interfaces.IBreadcrumb)

>>> request = TestRequest()
>>> breadcrumbs = zope.component.getMultiAdapter(
... (office, request), interfaces.IBreadcrumbs)
>>> list(breadcrumbs.crumbs)
[{'url': 'http://127.0.0.1/office',
'activeURL': True,
'name': u'Zope Foundation'}]
4 changes: 3 additions & 1 deletion src/z3c/breadcrumb/browser.py
Expand Up @@ -60,8 +60,10 @@ def crumbs(self):

objects.reverse()
for object in objects:
info = zope.component.getMultiAdapter(
info = zope.component.queryMultiAdapter(
(object, self.request), interfaces.IBreadcrumb)
if info is None:
continue
yield {'name': info.name,
'url': info.url,
'activeURL': info.activeURL}
Expand Down

0 comments on commit d943554

Please sign in to comment.