[Zope3-dev] implementing title_or_id

Garrett Smith garrett@mojave-corp.com
Thu, 10 Apr 2003 14:04:49 -0500


I'm trying to get my head around some of the Zope 3 concepts and have a
simple problem that I hope will be illustrative for me.

I want to display something akin to title_or_id for a component. I'm
envisioning a function that checks the following, in order:

 - a 'title' attribute for the component
 - a Dublin Core 'title' annotation
 - a 'title' annotation from another source
 - the component id

Either of the following uses would be fine:

  1 - tal:content=3D"context/title_or_id"
  2 - tal:content=3D"views/context_utils/title_or_id"

I've (partially) implemented the second form, since it seems to follow
established patterns.

Questions:

- When "plugging" in new functionality meant to be used only in page
templates, is the preferred approah to use a view, as in option 2 above?


- Is it even possible, per option 1 above, to specify a "wrapper" class
to add new functionality to components? I understand this is exactly
what adapters do, but I've only seen this in action in Python modules
using getAdpater. It's not clear to me how to get this going in TALES,
ala option 1.

- Given a context, what is the recommended approach for retrieving the
component ID? I understand that the component's container keeps track of
this, but it's not clear to me how the component itself can track this
down.

Thanks.

Garrett Smith