Conditional imports in ZTUtils/__init__.py
ZTUtils/__init__.py contains code like this: if sys.modules.has_key('Zope'): # import things This is causing me repeated headaches when writing tests, because it assumes/dictates a certain module import order. Can this go away, please? I mean we know we are running Zope, don't we? If there are no objections I will remove the condition on 2_7-branch and trunk. Tests pass just fine without it. Stefan -- The time has come to start talking about whether the emperor is as well dressed as we are supposed to think he is. /Pete McBreen/
Stefan H. Holek wrote:
ZTUtils/__init__.py contains code like this:
if sys.modules.has_key('Zope'):
# import things
This is causing me repeated headaches when writing tests, because it assumes/dictates a certain module import order. Can this go away, please? I mean we know we are running Zope, don't we?
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. Cheers, Evan @ 4-am
On Tue, 05 Oct 2004 09:47:11 -0500, Evan Simpson <evan@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
participants (3)
-
Evan Simpson -
Fred Drake -
Stefan H. Holek