[Zodb-checkins] CVS: Packages/ZEO - fap.py:1.2 start.py:1.19 __init__.py:1.6

Jim Fulton jim@digicool.com
Sun, 1 Apr 2001 14:38:36 -0400 (EDT)


Update of /cvs-repository/Packages/ZEO
In directory korak:/tmp/cvs-serv18812

Modified Files:
	fap.py start.py __init__.py 
Log Message:
Changed the way we try to find ZServer to take advantage of the known
location of the start.py script (when it is used).



--- Updated File fap.py in package Packages/ZEO --
--- fap.py	2001/03/27 23:36:23	1.1
+++ fap.py	2001/04/01 18:38:34	1.2
@@ -90,47 +90,54 @@
 """
 import sys
 
-# 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 
-except:
-    # Try a little harder to import ZServer
+def whiff(where):
+    if not where: return 0
     import os, imp
-    try: m=imp.find_module('ZServer', ['.'])
-    except:
-        try: m=imp.find_module('ZServer', [os.path.join('..','..')])
-        except:
-            import asyncore
-        else:
-            sys.path.append(os.path.join('..','..'))
-            from ZServer.medusa import asyncore 
-    else:
-        sys.path.append('.')
+    try: m=imp.find_module('ZServer', [where])
+    except: return 0
+    else: return 1
+    
+
+def fap(where=''):
+    # 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 
+    except:
+        # Try a little harder to import ZServer
+        import os, imp
 
-if sys.version[:1] < '2' and asyncore.loop.func_code.co_argcount < 3:
-    raise ImportError, 'Cannot import an up-to-date asyncore'
+        for location in where, '.', os.path.join('..','..'):
+            if whiff(location):
+                sys.path.append(location)
+                try: 
+                    from ZServer.medusa import asyncore 
+                except:
+                    import asyncore
+                break
 
-sys.modules['ZEO.asyncore']=asyncore
+    if sys.version[:1] < '2' and asyncore.loop.func_code.co_argcount < 3:
+        raise ImportError, 'Cannot import an up-to-date asyncore'
 
-# We need a recent version of cPickle too.
-if sys.version[:3] < '1.6':
-    try:
-        from ZODB import cPickle
-        sys.modules['ZEO.cPickle']=cPickle
-    except:
-        # Try a little harder
+    sys.modules['ZEO.asyncore']=asyncore
+
+    # We need a recent version of cPickle too.
+    if sys.version[:3] < '1.6':
+        try:
+            from ZODB import cPickle
+            sys.modules['ZEO.cPickle']=cPickle
+        except:
+            # Try a little harder
+            import cPickle
+    else:
         import cPickle
-else:
-    import cPickle
 
-import cStringIO
-p=cPickle.Pickler(cStringIO.StringIO(),1)
-try:
-    p.fast=1
-except:
-    raise ImportError, 'Cannot import an up-to-date cPickle'
+    import cStringIO
+    p=cPickle.Pickler(cStringIO.StringIO(),1)
+    try:
+        p.fast=1
+    except:
+        raise ImportError, 'Cannot import an up-to-date cPickle'
 

--- Updated File start.py in package Packages/ZEO --
--- start.py	2001/03/28 21:55:06	1.18
+++ start.py	2001/04/01 18:38:34	1.19
@@ -207,7 +207,8 @@
         elif o=='-d': detailed=1
         elif o=='-s': Z=0
 
-    import fap # fixup asyncore/cPickle dependencies
+    import fap
+    fap.fap(directory(me, 4)) # fixup asyncore/cPickle dependencies
 
     if port is None and unix is None:
         print usage

--- Updated File __init__.py in package Packages/ZEO --
--- __init__.py	2001/03/27 23:39:02	1.5
+++ __init__.py	2001/04/01 18:38:34	1.6
@@ -83,4 +83,5 @@
 # 
 ##############################################################################
 
-import fap # fixup asyncore/cPickle dependencies
+import fap
+fap.fap() # fixup asyncore/cPickle dependencies