[Zope-dev] Re: Conditional imports in ZTUtils/__init__.py

Fred Drake fdrake at gmail.com
Tue Oct 5 11:07:05 EDT 2004


On Tue, 05 Oct 2004 09:47:11 -0500, Evan Simpson <evan at 4-am.com> wrote:
 > This is part of my attempt to allow the various bits of ZPT to work
 > outside of Zope.  It assumes that the presence of the 'Zope' module is a
 > reliable test.  Perhaps this is a YAGNI, or perhaps there's a better way
 > of accomodating non-Zope users.

I've been recommending people wanting to use page templates outside of
Zope use the version from Zope 3.  I've not had time to follow-up with
the people that have been experimenting with it, though.

The code in ZTUtils' __init__.py is scary, partly because of the
import-order issue.  If the condition should remain at all, it should
be implemented using the usual pattern::

    try:
        import Zope
    except ImportError:
        # extra stuff goes here
        ...

The assignments could be made non-conditional without introducing
problems, so they should be.

I'm not sure what the intent of the additional imports is; that seems
very strange since there's no alternative implementation if the Zope
package hasn't been imported.


  -Fred

-- 
Fred L. Drake, Jr.    <fdrake at gmail.com>
Zope Corporation


More information about the Zope-Dev mailing list