[Zope3-Users] Re: ZCML, practicality, purity (was "Excellent
perspective...")
Shane Hathaway
shane at hathawaymix.org
Fri Dec 23 13:04:53 EST 2005
Jeff Shell wrote:
> And I think that's where I worry. With ZCML, name resolution happens
> very late. This seems to cut down on the problems that I've had with
> Zope 2 style configuration. If imports are in the top of the module,
> as most developers are used to doing, then they're executed as the
> module is imported for the first time. This is why I don't want
> 'configure.py' to be imported by other code if it can be helped.
Zope 2 imports are ugly because of side effects. In the absence of side
effects, it's better to import early to reveal ImportErrors early. This
is probably the reason ZCML actually evaluates imports earlier than you
suggest.
> 'import' is better and cleaner, but it's a situation where I worry
> about side effects unless the imports are outside of the top level of
> these hypothetical 'configure.py' modules.
We've provided developers a way to achieve configuration with no side
effects. I think this is a major accomplishment in the Python
community--until now, there was no standard way to avoid side effects in
Python code in general. With that problem solved, we should stop
worrying about import side effects and make this new functionality
thoroughly easy to use in all Python code.
Hmm... now that I think of it that way, maybe it would be perfectly
appropriate to create a Python-only ZCML for use outside Zope. Then
Zope could use it if it wants to.
Shane
More information about the Zope3-users
mailing list