9.
Implementation of the Generic Listing View Components (by Alec)
Up one level
My suggestion is that these be implemented as a series of ViewletManagers, where each viewlet is a representation of a list element. There would be a few simple interfaces involved. First the interfaces describing a list items and actions available on these list items:
class IActionItems(Interface):You would then register adapters from each of your potential list items to IListItem. These adapters would likely be incredibly trivial. Then you would register the relevant viewlet managers and viewlets. You would have a named viewlet manager for each type of potential list item ('comment_listing', 'amendment_listing', ...) these implementations would all use the same basic implementation, changing only the content type they choose to list and the name they are registered under.
"""A description of an action available on an object"""
# This may need to be generalized a bit to support actions which
# are more complex than a simple link
title=TextLine(u"Title")
description=TextLine(u"Description")
url=URI(u"Action URL")
category=TextLine(u"Action Category")
class IListItem(Interface):
"""An interface to describe an object which is part of a listing"""
title = TexLine(u"Title")
description = Text(u"Description")
actions = List(u"Actions",
description=u"List of Actions Available on the Item",
value_type=Object(u"Action Item",
interface=IActionItem))
Anyone who ends up making your architectural decisions or doing development should read and understand the very thorough README.txt included in zope.viewlet, which describes a similar pattern for building an extensible folder contents listing using viewlets.
The base implementation of the viewlet manager would get the objects of the desired type (possibly batched), and lookup a viewlet corresponding to each object (a viewlet adapts a context, request, view and the viewlet manager itself). Internally the viewlet would make the adaptation to IListType to get the desired data, and would render some relevant html for that piece. More specific viewlets would be registered for each object type (comment, amendment, etc.) as needed, but 90% of the implementation would remain the same, and these more specific renderings could be added incrementally.
Useful Reading
The main text that developers and architects should read (aside from standard Zope and Plone stuff) is 'Web Component Development with Zope 3' by Philipp von Weitershausen.
Philipp's site also has a lot of useful info, particularly regarding using this stuff in Zope 2. Additionally, Martin Aspeli will be publishing a book on development with Plone 3.0 in the near future, and that will certainly be worth a
look.
Alec.