[Zope3-Users] Utility or Content Component?

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Jan 4 08:29:48 EST 2005

On Sunday 02 January 2005 13:41, Florian Lindner wrote:
> What is the best way to do that?
> a) a local utility?
> b) a content component which is placed in the home folder
> c) a folderish content component which replaces the home folder
> I've some doubts with b, because the component does not contain content, so
> I don't think it's good to use a content component for that
> At the moment I prefer c.
> What is the best Zope way?

I think the best way would be to write an adapter from `IFolder` to 
`IOwnerSearch` (for example):

  >>> from zope.interface import Interface, implements

  >>> class IOwnerSearch(Interface):
  ...     def getObjectsOwnedBy(owner):
  ...         "Find all objects owned by `owner`."

  >>> class OwnerSearch(object):
  ...     implements(IOwnerSearch)
  ...     def __init__(self, context):
  ...         self.context = context
  ...     def getObjectsOwnedBy(owner):
  ...         ...

You can then use the adapter as follows:

  >>> IOwnerSearch(home).getObjectsOwnedBy(florian)

Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training

More information about the Zope3-users mailing list