[Zope-CVS] CVS: Products/Ape - __init__.py:1.3
Shane Hathaway
shane@zope.com
Wed, 9 Apr 2003 23:10:18 -0400
Update of /cvs-repository/Products/Ape
In directory cvs.zope.org:/tmp/cvs-serv32010
Modified Files:
__init__.py
Log Message:
Moved apelib into a "lib" subdirectory. This simplified the
Python hacking required to make apelib a top-level package. Sorry
about the flood of checkins, but CVS makes a move like this quite painful.
=== Products/Ape/__init__.py 1.2 => 1.3 ===
--- Products/Ape/__init__.py:1.2 Sat Mar 15 20:13:45 2003
+++ Products/Ape/__init__.py Wed Apr 9 23:09:47 2003
@@ -16,20 +16,18 @@
$Id$
"""
+import os
import sys
-import apelib
-if not sys.modules.has_key('apelib'):
- # Sneaky: make apelib available as a top-level package.
- apelib.__name__ = 'apelib'
- sys.modules['apelib'] = apelib
+try:
+ import apelib
+except ImportError:
+ # Import the copy of apelib from 'lib' by temporarily changing sys.path.
+ old_path = sys.path[:]
+ here = __path__[0]
+ sys.path.insert(0, os.path.join(here, 'lib'))
+ import apelib
+ sys.path[:] = old_path
-# The following code carefully avoids importing apelib.zope2 as
-# "Products.Ape.apelib.zope2", which would lead to duplicate classes
-# and interfaces. That's the price we pay for being sneaky. ;-)
-
-code = """
from apelib.zope2.setup import patches, dbtab
patches.applyPatches()
-"""
-exec code in {}