On Friday 01 June 2007 16:01, Lorenzo Gil Sanchez wrote: > def getFactoriesForObject(obj): > factories = [] > ifaces = tuple(zope.interface.providedBy(obj)) > for iface in ifaces: > for name, factory in zope.component.getFactoriesFor(iface): > factoryIfaces = tuple(factory.getInterfaces()) > if ifaces == factoryIfaces and name not in factories: > factories.append(name) > return factories > > I works quite well for content types objects (the ones I'm interested > in) but I'm curious about why this function return two factories in many
I think APIDOC provides that information as well. > cases: > >>> folder = zope.app.folder.folder.Folder() > >>> getFactoriesForObject(folder) > > [u'zope.app.content.Folder', > 'BrowserAdd__zope.app.folder.folder.Folder'] > > Is that because the <browser:addMenuItem> ZCML directive adding always a > factory for its class attribute? Yep, exactely. :-) > I'm curious about what zope gurus thing about my function and if anybody > think if could be useful in zope.component. I think it is not that useful. In fact, I would like to see the explicit factory support to be gone from zope.component, because it can be simply implemented using adapters. Regards, Stephan -- Stephan Richter CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training _______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users