[Zope-CMF] call opaque items others than 'talkback' in
CMFCore/CMFCatalogAware.py
Grégoire Weber
gregoire.weber at switzerland.org
Mon Aug 11 13:34:22 EDT 2003
Hi all,
I propose the following to allow other opaque items than 'talkback'
to be called on 'manage_after*' and 'manage_before*' events.
The proposed code change is fully backwards compatible.
Comments?
Gregoire
-------------------------------------------------------------------------
Change CMFCore/CMFCatalogAware.py (diff is done on the current HEAD):
$ diff CMFCatalogAware.py CMFCatalogAware_New.py
24a25
> from Interfaces.ICallableOpaqueItem import ICallableOpaqueItem
113,115c114,118
< # Since 'talkback' is the only opaque item on content
< # right now, I will return that. Should be replaced with
< # a list of tuples for every opaque item!
---
> items = []
>
> # Call 'talkback knowing that it is an opaque item.
> # This will remain here as long as the a discussion item does
> # not implement ICallableOpaqueItem (backwards compatibility).
119,120c122,134
< return ((talkback.id, talkback),)
< return ()
---
> items.append((talkback.id, talkback))
>
> # Other opaque items than 'talkback' may have callable
> # manage_after* and manage_before* methods.
> # Loops over all attributes and checks if they implement
> # ICallableOpaqueItem.
> for name in self.__dict__.keys():
> if not name.startswith('_'): # XXX Does that make sense?
> obj = getattr(self, name)
> if ICallableOpaqueItem.isImplementedBy(obj):
> items.append((obj.id, obj))
>
> return tuple(items)
-------------------------------------------------------------------------
New interface in CMFCore/Interfaces/ICallableOpaqueItem.py:
class ICallableOpaqueItem(Interface):
"""Marker interface for callable opaque items
"""
_____________________________________
Grégoire Weber
mailto:gregoire.weber at switzerland.org
More information about the Zope-CMF
mailing list