[z3-five] Re: Some design questions
Philipp von Weitershausen
philipp at weitershausen.de
Mon Apr 18 19:58:40 MEST 2005
Andreas Jung wrote:
> In TextIndexNG2 I worked a lot with auto-configured registries for
> parsers (by language), converters (by mime-type), stopwords (by
> language) etc. For a given key the registry returned a corresponding
> class or class instance....lots of implicit magic....In V3 I want to
> make things more configurable. What is the way to go? Extending ZCML?
No need to write your own ZCML directives (at least for your use cases,
I think). I think most of your use cases can be covered with named
utilities. For example, if you wanted a list of stopwords for German,
you'd do:
german_stopwords = zapi.getUtility(IStopWords, 'de')
So, in short, all stop-word objects are utilities that provide
IStopWords and their registration name is the country/language code. The
same thing would most probably make sense for converters (utility name
would be the mime type) and the parsers (name would be the
country/language code again).
> Another problem is efficiency....if an index handles only one
> language then subsequent lookups for the same language dependant
> classes (always the german stopwords etc.) must be cached somehow (it
> does not make sense to re-read the same stopword files over and over
> again).
I can only recommend one thing, especially when you're doing a rewrite
of something: Write clean code first and optimize later!
Philipp
More information about the z3-five
mailing list