[Zope3-Users] Re: Get classes implementing Interface

Florian Lindner mailinglists at xgm.de
Sun Jan 8 10:01:35 EST 2006


Am Freitag, 30. Dezember 2005 13:30 schrieb Philipp von Weitershausen:
> 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
> UtilityVocabulary.

Hi,
I do it this way now:

            utils =  getUtilitiesFor(IFactory)
            self.objects = {}
            for i in utils:
                if IContainer in i[1].getInterfaces():

the UtilityVocabulary gives the same result as getUtilitiesFor.
But that does not list all classes, for example there is no class of the 
normal Folder.

Florian


More information about the Zope3-users mailing list