Commit ccb4748d authored by Jim Fulton's avatar Jim Fulton

Redid ZServer search to use package path info.

parent aa0d4f47
......@@ -88,40 +88,40 @@
Try to fix up the imports of these to make these dependencies work,
localizing the hacks^H^H^H^H^Hchanges here.
"""
import sys
import sys, os
def whiff(where):
if not where: return 0
import os, imp
import imp
try: m=imp.find_module('ZServer', [where])
except: return 0
else: return 1
def fap(where=''):
def fap():
# if we are using an old version of Python, our asyncore is likely to
# be out of date. If ZServer is sitting around, we can get a current
# version of ayncore from it. In any case, if we are going to be used
# with Zope, it's important to use the version from Zope.
try:
from ZServer.medusa import asyncore
import ZServer
except:
# Try a little harder to import ZServer
import os, imp
location = package_home()
location = os.path.split(location)[0]
location = os.path.split(location)[0]
location = os.path.split(location)[0]
if whiff(location):
sys.path.append(location)
try:
import ZServer
except:
pass
asyncore = None
for location in where, '.', os.path.join('..','..'):
if whiff(location):
sys.path.append(location)
try:
from ZServer.medusa import asyncore
except:
import asyncore
break
if asyncore is None:
import asyncore
import asyncore
if sys.version[:1] < '2' and asyncore.loop.func_code.co_argcount < 3:
raise ImportError, 'Cannot import an up-to-date asyncore'
......@@ -146,3 +146,16 @@ def fap(where=''):
except:
raise ImportError, 'Cannot import an up-to-date cPickle'
def package_home():
m=sys.modules[__name__]
if hasattr(m,'__path__'):
r=m.__path__[0]
elif "." in __name__:
from string import rfind
r=sys.modules[__name__[:rfind(__name__,'.')]].__path__[0]
else:
r=__name__
return os.path.join(os.getcwd(), r)
fap()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment