[Checkins] SVN: zc.recipe.zope3instance/trunk/ Updated to use the new zc.recipe.egg api.

Jim Fulton jim at zope.com
Thu Jun 29 17:52:32 EDT 2006


Log message for revision 68924:
  Updated to use the new zc.recipe.egg api.
  

Changed:
  U   zc.recipe.zope3instance/trunk/README.txt
  D   zc.recipe.zope3instance/trunk/setup.cfg
  U   zc.recipe.zope3instance/trunk/setup.py
  U   zc.recipe.zope3instance/trunk/src/zc/recipe/zope3instance/__init__.py

-=-
Modified: zc.recipe.zope3instance/trunk/README.txt
===================================================================
--- zc.recipe.zope3instance/trunk/README.txt	2006-06-29 21:04:45 UTC (rev 68923)
+++ zc.recipe.zope3instance/trunk/README.txt	2006-06-29 21:52:31 UTC (rev 68924)
@@ -1,8 +1,11 @@
 Recipe for createing a Zope 3 instance
 ======================================
 
-This recipe takes the following options:
+This recipe creates a Zope instance that has been extended by a
+collection of eggs.
 
+The recipe takes the following options:
+
 zope3 
    The name of a section providing a Zope 3 installation definition.
    This defaults to zope3.  The section is required to have a 
@@ -18,11 +21,9 @@
 user
    The user name and password for manager user
 
-distribution
+eggs
    One or more requirements for distributions to be included.
 
-   THIS WILL SOON BE RENAMED TO EGGS
-
 zcml
 
    If specified, provides the list of package ZCML files to include in

Deleted: zc.recipe.zope3instance/trunk/setup.cfg
===================================================================
--- zc.recipe.zope3instance/trunk/setup.cfg	2006-06-29 21:04:45 UTC (rev 68923)
+++ zc.recipe.zope3instance/trunk/setup.cfg	2006-06-29 21:52:31 UTC (rev 68924)
@@ -1,3 +0,0 @@
-[egg_info]
-tag_build = .dev
-tag_svn_revision = 1

Modified: zc.recipe.zope3instance/trunk/setup.py
===================================================================
--- zc.recipe.zope3instance/trunk/setup.py	2006-06-29 21:04:45 UTC (rev 68923)
+++ zc.recipe.zope3instance/trunk/setup.py	2006-06-29 21:52:31 UTC (rev 68924)
@@ -3,7 +3,7 @@
 name = "zc.recipe.zope3instance"
 setup(
     name = name,
-    version = "1.0",
+    version = "1.0.0a1",
     author = "Jim Fulton",
     author_email = "jim at zope.com",
     description = "ZC Buildout recipe for defining a Zope 3 instance",

Modified: zc.recipe.zope3instance/trunk/src/zc/recipe/zope3instance/__init__.py
===================================================================
--- zc.recipe.zope3instance/trunk/src/zc/recipe/zope3instance/__init__.py	2006-06-29 21:04:45 UTC (rev 68923)
+++ zc.recipe.zope3instance/trunk/src/zc/recipe/zope3instance/__init__.py	2006-06-29 21:52:31 UTC (rev 68924)
@@ -2,13 +2,14 @@
 import zc.buildout
 import zc.recipe.egg
 
-class Recipe(zc.recipe.egg.Egg):
+class Recipe:
     # Need to think about the inheritence interface
     # it *is* reasonable to think about instances as an
     # extension of the basic egg/script-generation model.
 
     def __init__(self, buildout, name, options):
-        zc.recipe.egg.Egg.__init__(self, buildout, name, options)
+        self.egg = zc.recipe.egg.Egg(buildout, name, options)
+        self.options, self.name = options, name
 
         options['zope3'] = options.get('zope3', 'zope3')
         options['database-config'] = buildout[options['database']]['zconfig']
@@ -24,33 +25,22 @@
         
         options = self.options
         location = options['location']
+
+        requirements, ws = self.egg.working_set()
+
         if os.path.exists(location):
-            return location
 
-        # Gather information on extra distros. We should be able to
-        # inherit the next 2 statements, but Egg doesn't provide a
-        # subclassing api
-        
-        distributions = [
-            r.strip()
-            for r in options.get('distribution', self.name).split('\n')
-            if r.strip()
-            ]
+            # See is we can stop.  We need to see if the working set path
+            # has changed.
+            saved_path_path = os.path.join(location, 'etc', '.eggs')
+            if os.path.isfile(saved_path_path):
+                if (open(saved_path_path).read() ==
+                    '\n'.join([d.location for d in ws])
+                    ):
+                    return location
 
-        if self.buildout['buildout'].get('offline') == 'true':
-            ws = zc.buildout.easy_install.working_set(
-                distributions, options['executable'],
-                [options['_d'], options['_e']]
-                )
-        else:
-            ws = zc.buildout.easy_install.install(
-                distributions, options['_e'],
-                links = self.links,
-                index = self.index, 
-                executable = options['executable'],
-                always_unzip=options.get('unzip') == 'true',
-                path=[options['_d']]
-                )
+            # The working set has changed.  Blow away the instance.
+            shutil.rmtree(location)
         
         # What follows is a bit of a hack because the instance-setup mechanism
         # is a bit monolithic.  We'll run mkzopeinstabce and then we'll
@@ -67,6 +57,9 @@
             ) == 0
 
         try:
+            # Save the working set:
+            open(os.path.join(location, 'etc', '.eggs'), 'w').write(
+                '\n'.join([d.location for d in ws]))
 
             # Now, patch the zodb option in zope.conf
             zope_conf_path = os.path.join(location, 'etc', 'zope.conf')



More information about the Checkins mailing list