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:
> 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.
> >>> folder = zope.app.folder.folder.Folder()
> >>> getFactoriesForObject(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.
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
Zope3-users mailing list