[Zope3-Users] Re: Get classes implementing Interface

Jim Fulton jim at zope.com
Sat Dec 31 01:50:31 EST 2005

Florian Lindner wrote:
> Am Freitag, 30. Dezember 2005 17:45 schrieb Jim Fulton:
>>Philipp von Weitershausen wrote:
>>>Florian Lindner wrote:
>>>>my first use case is that I want to enhance the HomefolderManager to make
>>>>it possible to select something else than a Folder to be created
>>>>automatically. Right now I have forked a version of the
>>>>HomefolderManager and just changed in the code. But I would like to have
>>>>a more generic solution and I'll also commit it back to the trunk.
>>>>For that I want all classes implementing IContainer (and IContentType ?)
>>>>and let the user select on in the configuration dialog of the
>>>>HomefolderManager. More use caess probably show up in my project later,
>>>>but nothing fixed at this time.
>>>So what you want is to create objects. Classes are just an
>>>implementation detail to creating objects :). Factories create objects,
>>>whether they're from a class is immaterial.
>>>So, what you want is not a list of classes but a list of factories that
>>>can create IContainers. This is possible by using
>>>zapi.getUtilitiesFor(IFactory) and then checking each factory's
>>>getInterfaces() method whether IContainer is a part of the returned
>>>result. I would probably base an implementation of all on the
>>I'll also note that the use case is also directly addressed through
>>containment constraints.  You can say that a container
>>should only contain objects of some given types and you will get
>>just those types in the add list.
> But the HomeFolderManager is not a container itself it's just a utility that 
> creates container upon requests. And I want to make choosable which container 
> to create. Or do I misunderstand you?

I missunderstood you.  I'm not familiar with HomeFolderManager.
In any case, the approach taken for containment constraints,
which Philipp sketched above, should be applicable.


Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org

More information about the Zope3-users mailing list