[Zope-CMF] [CMF 2.1] opaque items calls make performance issue
Martin Aspeli
optilude+lists at gmail.com
Sat Aug 8 22:48:46 EDT 2009
Wichert Akkerman wrote:
> On 2009-8-8 11:53, Hanno Schlichting wrote:
>> On Sat, Aug 8, 2009 at 12:14 AM, Charlie Clark<charlie at begeistert.org> wrote:
>>> Is the patch for Plone or CMF?
>> It's for Plone, I guess. The "problem is solved" in Plone 4.0 itself
>> (via monkey-patching CMF).
>>
>>> If it's for CMF then you should consider simply submitting a patch or
>>> opening a branch. But before you write any package I would like to know a
>>> little more about what exactly you want to do.
>> The problem is the entire concept of opaque items. The only places I
>> know they are still in use is the "talkback" objects as used by the
>> discussion machinery in CMF. CMFUid also claims to implement the
>> concept, but doesn't actually need any of the functionality, since it
>> has its own event subscribers to deal with things.
>>
>> So the problem starts in
>> CMFCore.CMFCatalogAware.dispatchToOpaqueItems, with the nice line:
>>
>> for opaque in ob.opaqueValues():
>>
>> which in turn calls later on the opaqueItems method which contains this beauty:
>>
>> self_base = aq_base(self)
>> for name in self_base.__dict__.keys()
>> obj = getattr(self, name)
>> if ICallableOpaqueItem.providedBy(obj):
>> items.append((obj.getId(), obj))
That's just *nuts*!
>> The whole method redispatches any IObjectEvent fired on an
>> IOpaqueItemManager to any opaque item in it. In doing so, it needs to
>> load every single entry in the objects __dict__ to see if it is an
>> ICallableOpaqueItem.
>>
>> It happens that the CMFCatalogAware base class is such an
>> IOpaqueItemManager, so any essentially any content object gets this
>> treatment.
>
> Could it be that this considers dexterity content to be opaque items? I
> have some code where events are recursively re-dispatched by CMF and I
> suspect this is why.
I can't see how that could happen. A Dexterity content item is a CMF
content item, with the same base classes. And it certainly doesn't
implement ICallableOpaqueItem.
(Do note that Dexterity has an event handler to do some indexing,
because in Plone 3/CMF 2.1 at least, it didn't happen automatically).
Martin
--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book
More information about the Zope-CMF
mailing list