[Zope-CMF] [CMF 2.1] opaque items calls make performance issue

Hanno Schlichting hanno at hannosch.eu
Sat Aug 8 05:53:26 EDT 2009


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))

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.

Now imagine you edit the title of a folderish type containing 1000+
items. Thanks to the above you will also load all items it contains
from the database. Any add/delete/edit operation on a large folderish
type suddenly becomes increasingly slow.

On the Plone level we decided to no longer support the opaque items
concept except for the talkback item. That simplifies the whole
overhead into a simple attribute lookup for that one item and avoids
the overhead of checking every contained item.

I don't know how such a feature removal or deprecation would be
handled on the CMF level.

Hanno


More information about the Zope-CMF mailing list