[Checkins] SVN: zc.recipe.zeoinstance/trunk/ commiting partial progress due to an svn limitation

Jim Fulton jim at zope.com
Wed Jul 19 14:33:10 EDT 2006


Log message for revision 69208:
  commiting partial progress due to an svn limitation

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

-=-
Modified: zc.recipe.zeoinstance/trunk/README.txt
===================================================================
--- zc.recipe.zeoinstance/trunk/README.txt	2006-07-19 17:40:52 UTC (rev 69207)
+++ zc.recipe.zeoinstance/trunk/README.txt	2006-07-19 18:33:09 UTC (rev 69208)
@@ -1,4 +1,4 @@
-Recipe for createing a Zope 3 instance
+Recipe for creating a ZEO instance
 ======================================
 
 This recipe creates a Zope instance that has been extended by a
@@ -6,9 +6,9 @@
 
 The recipe takes the following options:
 
-zope3 
+zeo 
    The name of a section providing a Zope 3 installation definition.
-   This defaults to zope3.  The section is required to have a 
+   This defaults to zeo.  The section is required to have a 
    location option giving the location of the installation.  This
    could be a section used to install a part, like a Zope 3 checkout,
    or simply a section with a location option pointing to an existing
@@ -18,67 +18,10 @@
    The name of a section defining a zconfig option that has a zodb
    section.
 
-user
-   The user name and password for manager user
-
-eggs
-   One or more requirements for distributions to be included.
-
-zcml
-
-   If specified, provides the list of package ZCML files to include in
-   the instance's package includes and their order.
-
-   By default, the ZCML files normally included in package-includes
-   are ommitted.  To includes these, include '*' in the list of
-   includes.
-
-   Each entry is a package name with an optional include type and file
-   name.  An package name can be optionally followed by a ':' and a
-   file name within the package.  The default file name is
-   configure.zcml.  The string '-meta' can be included between the
-   file name and the package name. If so, then the default file name
-   is meta.zcml and the include will be treated as a meta include.
-   Similarly for '-overrides'. For example, the include::
-
-      foo.bar
-
-   Causes the file named NNN-foo.bar-configure.zcml to be inserted
-   into package-includes containing:
-
-      <include package="foo.bar" file="configure.zcml" />
-
-   where NNN is a 3-digit number computed from the order if the entry
-   in the zcml option.
-
-   The include:
-
-      foo.bar-meta
-
-   Causes the file named NNN-foo.bar-meta.zcml to be inserted
-   into package-includes containing:
-
-      <include package="foo.bar" file="meta.zcml" />
-
-   The include:
-
-      foo.bar-overrides:x.zcml
-
-   Causes the file named NNN-foo.bar-overrides.zcml to be inserted
-   into package-includes containing:
-
-      <include package="foo.bar" file="x.zcml" />
-
       
 To do
 -----
 
 - Need tests
 
-- Hopefully, for Zope 3.4, we'll be able to make the instance-creation
-  process more modular, which will allow a cleaner implementation for
-  this recipe.
-
-- Support for multiple storages
-
 - Support for more configuration options.

Modified: zc.recipe.zeoinstance/trunk/setup.py
===================================================================
--- zc.recipe.zeoinstance/trunk/setup.py	2006-07-19 17:40:52 UTC (rev 69207)
+++ zc.recipe.zeoinstance/trunk/setup.py	2006-07-19 18:33:09 UTC (rev 69208)
@@ -1,6 +1,6 @@
 from setuptools import setup, find_packages
 
-name = "zc.recipe.zope3instance"
+name = "zc.recipe.zeoinstance"
 setup(
     name = name,
     version = "1.0.0a1",
@@ -9,15 +9,14 @@
     description = "ZC Buildout recipe for defining a Zope 3 instance",
     long_description = open('README.txt').read(),
     license = "ZPL 2.1",
-    keywords = "zope3 buildout",
+    keywords = "zodb zeo buildout",
     url='http://svn.zope.org/'+name,
 
     packages = find_packages('src'),
     include_package_data = True,
     package_dir = {'':'src'},
     namespace_packages = ['zc', 'zc.recipe'],
-    install_requires = ['zc.buildout', 'zope.testing', 'setuptools',
-                        'zc.recipe.egg'],
+    install_requires = ['zc.buildout', 'zope.testing', 'setuptools',],
     dependency_links = ['http://download.zope.org/distribution/'],
     entry_points = {'zc.buildout': ['default = %s:Recipe' % name]},
     )

Copied: zc.recipe.zeoinstance/trunk/src/zc/recipe/zeoinstance (from rev 69207, zc.recipe.zeoinstance/trunk/src/zc/recipe/zope3instance)

Modified: zc.recipe.zeoinstance/trunk/src/zc/recipe/zeoinstance/__init__.py
===================================================================
--- zc.recipe.zeoinstance/trunk/src/zc/recipe/zope3instance/__init__.py	2006-07-19 17:40:52 UTC (rev 69207)
+++ zc.recipe.zeoinstance/trunk/src/zc/recipe/zeoinstance/__init__.py	2006-07-19 18:33:09 UTC (rev 69208)
@@ -1,134 +1,67 @@
 import os, re, shutil
 import zc.buildout
-import zc.recipe.egg
 
+start_section = re.compile('\n[ \t]*<>[ \t]*\n').search
+end_section = re.compile('\n[ \t]*<>[ \t]*\n').search
+
 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):
-        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']
+        options['zeo'] = options.get('zeo', 'zeo')
+        self._getdbconfig()
         python = buildout['buildout']['python']
-        options['zope3-directory'] = buildout[options['zope3']]['location']
+        options['zeo-directory'] = buildout[options['zeo']]['location']
         options['location'] = os.path.join(
             buildout['buildout']['parts-directory'],
             self.name,
             )
-        options['scripts'] = '' # suppress script generation.
 
+    def _getdbconfig(self, options):
+        dbconfig = buildout[options['database']]['zconfig']
+        dbconfig = dbconfig[start_section(dbconfig).end(0):]
+        dbconfig = dbconfig[start_section(dbconfig).start(0):]
+        dbconfig = dbconfig[:end_section(dbconfig).end(0):]
+        options['database-config'] = dbconfig
+
     def install(self):
         
         options = self.options
         location = options['location']
 
-        requirements, ws = self.egg.working_set()
-
         if os.path.exists(location):
-
-            # 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
-
-            # The working set has changed.  Blow away the instance.
-            shutil.rmtree(location)
+            return 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
+        # is a bit monolithic.  We'll run mkzeoinstabce and then we'll
         # patch the result.  A better approach might be to provide independent
         # instance-creation logic, but this raises lots of issues that
         # need to be stored out first.
-        mkzopeinstance = os.path.join(options['zope3-directory'],
-                                      'bin', 'mkzopeinstance')
+        mkzeoinstance = os.path.join(options['zeo-directory'],
+                                      'bin', 'mkzeoinstance')
 
         assert os.spawnl(
             os.P_WAIT, options['executable'], options['executable'],
-            mkzopeinstance, '-d', location, '-u', options['user'],
-            '--non-interactive',
+            mkzeoinstance, location,
             ) == 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')
-            zope_conf = open(zope_conf_path).read()
-            zope_conf = (
-                zope_conf[:zope_conf.find('<zodb>')]
+            # Now, patch the zodb option in zeo.conf
+            zeo_conf_path = os.path.join(location, 'etc', 'zeo.conf')
+            zeo_conf = open(zeo_conf_path).read()            
+            zeo_conf = (
+                zeo_conf[:zeo_conf.find('<filestorage 1>')]
                 +
                 options['database-config']
                 +
-                zope_conf[zope_conf.find('</zodb>')+7:]
+                zeo_conf[zeo_conf.find('</filestorage>')+15:]
                 )
-            open(zope_conf_path, 'w').write(zope_conf)
+            open(zeo_conf_path, 'w').write(zeo_conf)
 
-            # Patch extra paths into binaries
-            path = "\n        '" + "',\n        '".join([
-                dist.location for dist in ws]) + "'\n        "
-            for script_name in 'runzope', 'debugzope', 'scriptzope':
-                script_path = os.path.join(location, 'bin', script_name)
-                script = open(script_path).read()
-                # don't look :/
-                script = script.replace(
-                    'sys.path[:] = [',
-                    'sys.path[:] = ['+path+'] + ['
-                    )
-                open(script_path, 'w').write(script)
-
-            # finally, add zcml files to package-includes
-            zcml = options.get('zcml')
-            if zcml:
-                includes_path = os.path.join(
-                    location, 'etc', 'package-includes')
-                zcml = zcml.split()
-                if '*' in zcml:
-                    zcml.remove('*')
-                else:
-                    shutil.rmtree(includes_path)
-                    os.mkdir(includes_path)
-
-                n = 0
-                package_match = re.compile('\w+([.]\w+)*$').match
-                for package in zcml:
-                    n += 1
-                    orig = package
-                    if ':' in package:
-                        package, filename = package.split(':')
-                    else:
-                        filename = None
-
-                    if '-' in package:
-                        package, suff = package.split('-')
-                        if suff not in ('configure', 'meta', 'overrides'):
-                            raise ValueError('Invalid zcml', orig)
-                    else:
-                        suff = 'configure'
-
-                    if filename is None:
-                        filename = suff + '.zcml'
-
-                    if not package_match(package):
-                        raise ValueError('Invalid zcml', orig)
-
-                    path = os.path.join(
-                        includes_path,
-                        "%3.3d-%s-%s.zcml" % (n, package, suff),
-                        )
-                    open(path, 'w').write(
-                        '<include package="%s" file="%s" />\n'
-                        % (package, filename)
-                        )
                     
         except:
             # clean up



More information about the Checkins mailing list