[Zope-CMF] CMFCatalogAware.dispatchToOpaqueItems madness

Matt Hamilton matth at netsight.co.uk
Thu Dec 18 16:54:01 EST 2008


I really don't understand this code, so maybe I'm missing something here, but
anyone know wtf the opaqueItem code does in CMFCore.CMFCatalogAware?!

Why does the opaqueItems method iterate through *every* attribute in the root of
the site causing all objects (including, at least in plone) all sub-objects of
folders to be woken up too):

    for name in self_base.__dict__.keys():
            obj = getattr(self, name)
            if ICallableOpaqueItem.providedBy(obj) \
                    or z2ICallableOpaqueItem.isImplementedBy(obj):
                items.append((obj.getId(), obj))

If it is looking for opaque items (I still don't know what these really are)
then why does it look in content objects too?!

How about the changes below?

    objectids = dict([(x,1) for x in self.objectIds()])                        
         
    for name in self_base.__dict__.keys():
        if name not in objectids:                                              
         
            obj = getattr(self, name)
            if ICallableOpaqueItem.providedBy(obj) \
                    or z2ICallableOpaqueItem.isImplementedBy(obj):
                items.append((obj.getId(), obj))

(that was probably all wrapped to hell)

Basically, I've got a production site which loads up several tens of thousands
of objects from the ZODB just to display the front page.  Madness.

-Matt

-- 
Matt Hamilton                                       matth at netsight.co.uk
Netsight Internet Solutions, Ltd.           Understand. Develop. Deliver
http://www.netsight.co.uk                             +44 (0)117 9090901
Web Design | Zope/Plone Development & Consulting | Co-location | Hosting



More information about the Zope-CMF mailing list