after looking the zope.component API I realized that there is a function
to get all the factories for an interface but there is no such thing for
Usually an object provides one or more interfaces, and one interface can
have a lot of factories registered for it. Merging this information I
want the factories that implements *all* the interfaces an object
Basically I want to know how (e.g. what factory was used) an object was
created by introspection.
I wrote this small function:
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:
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
>>> folder = zope.app.folder.folder.Folder()
Is that because the <browser:addMenuItem> ZCML directive adding always a
factory for its class attribute?
I'm curious about what zope gurus thing about my function and if anybody
think if could be useful in zope.component.
Zope3-users mailing list