Roger Ineichen wrote: > class LanguagesVocabulary(SimpleVocabulary): > """... languages from a translation domain.""" > > implements(ILanguagesVocabulary) > > def __init__(self, context, domain='zope'): > terms = [] > > # collect languages from translation domain > trans_domain = getUtility(ILocalTranslationDomain, domain) > languages = trans_domain.getAvailableLanguages() > > for lang in languages: > terms.append(SimpleTerm(lang, lang, lang)) > > terms.sort(lambda lhs, rhs: cmp(lhs.title, rhs.title)) > super(LanguagesVocabulary, self).__init__(terms) >
You can, of course, leave this as it is and implement the 'tiks' vocabulary as: def tiksLanguagesVocabulary(context): return LanguagesVocabulary(context, 'tiks') and then register that as a regular IVocabularyFactory utility, in case you're keen on saving lines in Python or just hesitant to create classes. > I could live with that, but I don't understand why I loose additional > to this the reusablility and also the readability in ZCML? I think <utility component=".tiksLanguagesVocabulary" name="Tiks Languages" /> reads quite well. > Philipp can you tell me why this is better if we loose the concept for > quick adding a new utility providing kws like the 'domain' attribute in > example. I explain this in the proposal: "First, it is the only directive to take arbitrary arguments and by this it defies one of the initial aspects of ZCML (which is being restricted to a certain set of directives and parameters)." > So this means if I need another LanguageVocabulary utility for a new > domain, I have to write new factory, just for use another > domain='foobar' attribute. > > Should we add the vocabulary directive to a higher level namespace What is a "higher level namespace"? Either way, I'd rather reduce the amount of namespaces we have (perhaps to just the 'zope' one and 'browser'). > or should we add it back to where it was. This proposal had been around for quite some time. Writing, reviewing and implementing it took quite an amount of my spare time. > Note the option to go > the new (simply but not reusable pure python) way is there in both concept. Not sure what you mean by this. > And, > what should we do with the factory and implement sub class directive > before they get (re)moved? Huh? Philipp _______________________________________________ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com