How to install zope.app.tree
- Download and install ActivePython
- Open Command Prompt
pypm install zope.app.tree
What is ZopeTree?
ZopeTree is a port of Philipp's Zope2 product ZopeTree. ZopeTree was meant to be a light-weight and easy-to-use static tree implementation, mainly designed for use in ZPTs. It was originally written because Zope2's ZTUtils.Tree was found to be too complicated and inflexible.
The ZTUtils package has not been ported to Zope3. Parts of it, like batching, have found their way into Zope3, though. Only support for static tree generation is not in the core.
How to use it
ZopeTree comes with several predefined views:
cookie_tree simple view using cookies for tree state storage.
folder_cookie_tree same as above, however only showing folders.
site_cookie_tree same as above, with the nearest site as root node.
root_cookie_tree same as above, with the root container as root node.
The example page template(s) in the browser package give an idea how to use these views for HTML templating.
The best way to customize ZopeTree is to define your own view for objects (usually '*'). If you want to use the cookie functionality, simply extend the cookie browser view:
from zope.app.tree.filters import OnlyInterfacesFilter from zope.app.tree.browser.cookie import CookieTreeView
def bendablesTree(self): # tree with only IBendables, but also show the folder # they're in filter = OnlyInterfacesFilter(IBendable, IFolder) return self.cookieTree(filter)
You can also write your own filters. All you have to do is implement the IObjectFindFilter interface (which is trivial):
from zope.interface import implements from zope.app.interfaces.find import IObjectFindFilter
class BendableFilter: implements(IObjectFindFilter)
def matches(self, obj) # only allow bendable objects return obj.isBendable()
License and Copyright
This product is released under the terms of the Zope Public License (ZPL) v2.1. See the ZopePublicLicense.txt file at the root of your Zope distribution.
Copyright (c) 2003 Philipp "philiKON" von Weitershausen Copyright (c) 2004 Zope Corporation and Contributors
- Converted from using zope.app.container to zope.container.
- Add compatibility for newer zope.traversing releases that require us
to explicitly set up testing. This also works with older releases.
- Get rid of zope.app.zapi dependency, replacing its uses with
- Clean up dependencies, move testing and rotterdam dependencies
to extra requires.
- Fix mailing list address to firstname.lastname@example.org instead of retired
email@example.com. Change cheeseshop to pypi in the package url.
- Replace __used_for__ in adapters.py with zope.component.adapts
calls to make more sense.
- Remove obsolete zpkg files, zcml include file for mkzopeinstance-based
installations, versions.txt that makes no sense now.
- Initial release independent of the main Zope tree.