[Zope3-dev] Re: <vocabulary> BBB
dev at projekt01.ch
dev at projekt01.ch
Thu May 18 16:33:18 EDT 2006
Hi Philipp
[...]
>
> dev at projekt01.ch wrote:
> >> I'm working on removing BBB warnings of our current app for 3.3.
> >> For the <vocabulay> directive it was possible to give the factory
> >> some parameters like this:
> >>
> >> <vocabulary
> >> name="doctype"
> >> factory="..vocab.ContainerVocabulary"
> >> containerName="doctype" />
> >>
> >> Now, with the <utility> directive that's not possible.
> >
> > Write a own factory like:
> >
> > class DocTypeContainerVocabulary(ContainerVocabulary):
> >
> > def __init__(self):
> > super(DocTypeContainerVocabulary, self).__init__()
> > self.containerName = 'doctype'
> >
> > and also you have to *patch* your class with :
> >
> > classProvides(DocTypeContainerVocabulary, IVocabularyFactory)
>
> This is unnecessarily complicated. Simply do:
>
> class DocTypeContainerVocabulary(ContainerVocabulary):
> containerName = 'doctype'
> zope.interface.classProvides(IVocabularyFactory)
right, that's simpler than my sample.
> Btw, the "classProvides" thing isn't "patching". Not sure
> what you mean, Roger, but it looks like you wanted to give
> this a negative connotation.
Ok, sorry that wasn't the target of the word *patching*.
But sure I'm not really happy with the additional python
code where we have to write and it smells to me like a
monky patch pattern if use classProvides outside of the
class definition.
Your example is much better in this part.
Regards
Roger Ineichen
More information about the Zope3-dev
mailing list