[Checkins] SVN: zc.recipe.zeo/branches/dev/ Initial version.
Jim Fulton
jim at zope.com
Mon Oct 30 07:10:23 EST 2006
Log message for revision 70994:
Initial version.
Changed:
A zc.recipe.zeo/branches/dev/README.txt
A zc.recipe.zeo/branches/dev/buildout.cfg
A zc.recipe.zeo/branches/dev/setup.py
A zc.recipe.zeo/branches/dev/src/
A zc.recipe.zeo/branches/dev/src/zc/
A zc.recipe.zeo/branches/dev/src/zc/__init__.py
A zc.recipe.zeo/branches/dev/src/zc/recipe/
A zc.recipe.zeo/branches/dev/src/zc/recipe/__init__.py
A zc.recipe.zeo/branches/dev/src/zc/recipe/zeo/
A zc.recipe.zeo/branches/dev/src/zc/recipe/zeo/README.txt
A zc.recipe.zeo/branches/dev/src/zc/recipe/zeo/__init__.py
A zc.recipe.zeo/branches/dev/src/zc/recipe/zeo/tests.py
-=-
Added: zc.recipe.zeo/branches/dev/README.txt
===================================================================
--- zc.recipe.zeo/branches/dev/README.txt 2006-10-30 11:46:21 UTC (rev 70993)
+++ zc.recipe.zeo/branches/dev/README.txt 2006-10-30 12:10:22 UTC (rev 70994)
@@ -0,0 +1,7 @@
+Recipes for working with ZEO
+****************************
+
+.. contents
+
+
+
Property changes on: zc.recipe.zeo/branches/dev/README.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: zc.recipe.zeo/branches/dev/buildout.cfg
===================================================================
--- zc.recipe.zeo/branches/dev/buildout.cfg 2006-10-30 11:46:21 UTC (rev 70993)
+++ zc.recipe.zeo/branches/dev/buildout.cfg 2006-10-30 12:10:22 UTC (rev 70994)
@@ -0,0 +1,15 @@
+[buildout]
+develop = .
+parts = zodb test
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = zc.recipe.zeo
+ ZODB3
+defaults = ['-s', 'zc.recipe.zeo']
+
+# Make sure we have a ZODB handy
+[zodb]
+recipe = zc.recipe.egg
+eggs = ZODB3
+scripts =
Property changes on: zc.recipe.zeo/branches/dev/buildout.cfg
___________________________________________________________________
Name: svn:eol-style
+ native
Added: zc.recipe.zeo/branches/dev/setup.py
===================================================================
--- zc.recipe.zeo/branches/dev/setup.py 2006-10-30 11:46:21 UTC (rev 70993)
+++ zc.recipe.zeo/branches/dev/setup.py 2006-10-30 12:10:22 UTC (rev 70994)
@@ -0,0 +1,23 @@
+from setuptools import setup, find_packages
+
+name = "zc.recipe.zeo"
+setup(
+ name = name,
+ version = "1.0.0a1",
+ author = "Jim Fulton",
+ author_email = "jim at zope.com",
+ description = "ZC Buildout recipe for working with ZEO",
+ license = "ZPL 2.1",
+ keywords = "zodb zeo buildout",
+ url='http://www.python.org/pypi/'+name,
+
+ packages = find_packages('src'),
+ include_package_data = True,
+ package_dir = {'':'src'},
+ namespace_packages = ['zc', 'zc.recipe'],
+ install_requires = [
+ 'zc.buildout',
+ 'zc.recipe.egg',
+ 'setuptools',],
+ entry_points = {'zc.buildout': ['default = %s:Instance' % name]},
+ )
Property changes on: zc.recipe.zeo/branches/dev/setup.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zc.recipe.zeo/branches/dev/src/zc/__init__.py
===================================================================
--- zc.recipe.zeo/branches/dev/src/zc/__init__.py 2006-10-30 11:46:21 UTC (rev 70993)
+++ zc.recipe.zeo/branches/dev/src/zc/__init__.py 2006-10-30 12:10:22 UTC (rev 70994)
@@ -0,0 +1,6 @@
+# namespace package boilerplate
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError, e:
+ from pkgutil import extend_path
+ __path__ = extend_path(__path__, __name__)
Property changes on: zc.recipe.zeo/branches/dev/src/zc/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zc.recipe.zeo/branches/dev/src/zc/recipe/__init__.py
===================================================================
--- zc.recipe.zeo/branches/dev/src/zc/recipe/__init__.py 2006-10-30 11:46:21 UTC (rev 70993)
+++ zc.recipe.zeo/branches/dev/src/zc/recipe/__init__.py 2006-10-30 12:10:22 UTC (rev 70994)
@@ -0,0 +1,6 @@
+# namespace package boilerplate
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError, e:
+ from pkgutil import extend_path
+ __path__ = extend_path(__path__, __name__)
Property changes on: zc.recipe.zeo/branches/dev/src/zc/recipe/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zc.recipe.zeo/branches/dev/src/zc/recipe/zeo/README.txt
===================================================================
--- zc.recipe.zeo/branches/dev/src/zc/recipe/zeo/README.txt 2006-10-30 11:46:21 UTC (rev 70993)
+++ zc.recipe.zeo/branches/dev/src/zc/recipe/zeo/README.txt 2006-10-30 12:10:22 UTC (rev 70994)
@@ -0,0 +1,201 @@
+Creating ZEO Instances
+**********************
+
+Note that at this time, the recipe is unix-centric. We'll add windows
+support in the future.
+
+The ZEO instance recipe (zc.recipe.zeoinstance) creates a ZEO
+instance. It takes a number of options:
+
+zeo
+ An distribution requirement for a distribution providing ZEO
+ software. This currently defaults to ZODB3.
+
+zdaemon
+ An distribution requirement for a distribution providing zdaemon
+ software. This currently defaults to ZODB3.
+
+database
+ The name of a section that has a zconfig option providing a
+ database definition.
+
+options
+ A collection of ZEO ZConfig options. These are given as name-value
+ pairs on separate lines.
+
+The recipe also supports the options defined by the zc.recipe.eggs
+recipe with the exception of the eggs, scripts, entry-points, and
+extra-paths options.
+
+Let's look at a basic example. We'll define a ZEO instace named
+'storage':
+
+ >>> write("buildout.cfg",
+ ... '''
+ ... [buildout]
+ ... parts = storage
+ ...
+ ... [foo]
+ ... zconfig =
+ ... <zodb>
+ ... <filestorage>
+ ... path = /var/foo/Data.fs
+ ... </filestorage>
+ ... </zodb>
+ ...
+ ... [storage]
+ ... recipe = zc.recipe.zeo
+ ... database = foo
+ ...
+ ... ''')
+
+Note that in this case, we provided a database section with an
+explicit zconfig option. Usually, we'll use another recipe, like the
+zc.recipe.filestorage recipe to define a database.
+
+If we run the buildout, we'll get a storage part:
+
+ >>> print system(join('bin', 'buildout')),
+ buildout: Installing storage
+
+ >>> ls('parts', 'storage')
+ - runzeo
+ - zdrun
+ - zeo.conf
+
+ >>> cat('parts', 'storage', 'zeo.conf')
+ # ZEO configuration file
+ #
+ # This file is generated. If you edit this file, your edits could
+ # easily be lost.
+ <BLANKLINE>
+ <zeo>
+ address 8100
+ </zeo>
+ <BLANKLINE>
+ <filestorage 1>
+ path = /var/foo/Data.fs
+ </filestorage>
+ <BLANKLINE>
+ <BLANKLINE>
+ <eventlog>
+ level info
+ <logfile>
+ path /sample-buildout/parts/storage/zeo.log
+ </logfile>
+ </eventlog>
+ <BLANKLINE>
+ <runner>
+ program /sample-buildout/parts/storage/runzeo
+ socket-name /sample-buildout/parts/storage/zeo.zdsock
+ daemon true
+ forever false
+ backoff-limit 10
+ exit-codes 0, 2
+ directory /sample-buildout/parts/storage
+ default-to-interactive true
+ python /usr/local/bin/python2.4
+ logfile /sample-buildout/parts/storage/zeo.log
+ </runner>
+
+ >>> cat('parts', 'storage', 'zdrun')
+ #!/usr/local/bin/python2.4
+ <BLANKLINE>
+ import sys
+ sys.path[0:0] = [
+ '/sample-buildout/eggs/ZODB3-3.7.0-py2.4-linux-i686.egg',
+ ]
+ <BLANKLINE>
+ import zdaemon.zdrun
+ <BLANKLINE>
+ if __name__ == '__main__':
+ zdaemon.zdrun.main()
+
+ >>> cat('parts', 'storage', 'runzeo')
+ #!/usr/local/bin/python2.4
+ <BLANKLINE>
+ import sys
+ sys.path[0:0] = [
+ '/sample-buildout/eggs/ZODB3-3.7.0-py2.4-linux-i686.egg',
+ ]
+ <BLANKLINE>
+ import ZEO.runzeo
+ <BLANKLINE>
+ if __name__ == '__main__':
+ ZEO.runzeo.main(
+ ["-C", '/sample-buildout/parts/storage/zeo.conf']
+ + sys.argv[1:])
+
+We also get a storage script in the buildout bin directory:
+
+ >>> cat('bin', 'storage')
+ #!/usr/local/bin/python2.4
+ <BLANKLINE>
+ import sys
+ sys.path[0:0] = [
+ '/sample-buildout/eggs/ZODB3-3.7.0-py2.4-linux-i686.egg',
+ ]
+ <BLANKLINE>
+ import ZEO.zeoctl
+ <BLANKLINE>
+ if __name__ == '__main__':
+ ZEO.zeoctl.main(
+ ["-C", '/sample-buildout/parts/storage/zeo.conf']
+ + sys.argv[1:])
+
+The zeo recipe also produces a zconfig option that can be used by
+other recipes. To see this, we'll create a recipe that that outputs
+the zconfig option produced for the storage:
+
+ >>> mkdir('recipes')
+ >>> write('recipes', 'setup.py',
+ ... '''
+ ... from setuptools import setup
+ ... setup(name='recipes',
+ ... entry_points={'zc.buildout': ['showconfig = showconfig:Recipe']},
+ ... )
+ ... ''')
+
+ >>> write('recipes', 'showconfig.py',
+ ... '''
+ ... class Recipe:
+ ... def __init__(self, buildout, name, options):
+ ... print buildout['storage']['zconfig']
+ ... def install(self):
+ ... return ()
+ ... def update(self):
+ ... pass
+ ... ''')
+
+ >>> write("buildout.cfg",
+ ... '''
+ ... [buildout]
+ ... develop = recipes
+ ... parts = storage showconfig
+ ...
+ ... [foo]
+ ... zconfig =
+ ... <zodb>
+ ... <filestorage>
+ ... path = /var/foo/Data.fs
+ ... </filestorage>
+ ... </zodb>
+ ...
+ ... [storage]
+ ... recipe = zc.recipe.zeo
+ ... database = foo
+ ...
+ ... [showconfig]
+ ... recipe = recipes:showconfig
+ ... ''')
+
+ >>> print system(join('bin', 'buildout')),
+ buildout: Develop: /sample-buildout/recipes/setup.py
+ <zodb>
+ <zeoclient>
+ server 8100
+ </zeoclient>
+ </zodb>
+ <BLANKLINE>
+ buildout: Updating storage
+ buildout: Installing showconfig
Property changes on: zc.recipe.zeo/branches/dev/src/zc/recipe/zeo/README.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: zc.recipe.zeo/branches/dev/src/zc/recipe/zeo/__init__.py
===================================================================
--- zc.recipe.zeo/branches/dev/src/zc/recipe/zeo/__init__.py 2006-10-30 11:46:21 UTC (rev 70993)
+++ zc.recipe.zeo/branches/dev/src/zc/recipe/zeo/__init__.py 2006-10-30 12:10:22 UTC (rev 70994)
@@ -0,0 +1,159 @@
+import re, os, logging
+import zc.buildout.easy_install
+import zc.recipe.egg
+
+start_section = re.compile('(^|\n)[ \t]*<[^>]+>[ \t]*\n').search
+end_section = re.compile('(^|\n)[ \t]*</[^>]+>[ \t]*\n').search
+
+logger = logging.getLogger('zc.recipe.zeo')
+
+class Instance:
+
+ def __init__(self, buildout, name, options):
+ self.name, self.options = name, options
+
+ options['location'] = os.path.join(
+ buildout['buildout']['parts-directory'],
+ self.name,
+ )
+
+ zeo_options = {}
+ for option in options.get('zeo-options', '').split('\n'):
+ option = option.strip()
+ if not option:
+ continue
+ option = option.split(' ', 1)
+ if (len(option) == 1) or not option[1].strip():
+ logger.error('%s: zeo-option, %s, has no value',
+ self.name, option[0]
+ )
+ raise zc.buildout.UserError("Invalid zeo-option", option[0])
+ zeo_options[option[0]] = option[1]
+
+ if 'address' not in zeo_options:
+ zeo_options['address'] = '8100'
+
+ self.zeo_options = '\n '.join([
+ ' '.join(option)
+ for option in zeo_options.iteritems()
+ ])
+
+ 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):]
+ dbconfig = dbconfig.replace('>', ' 1>', 1)
+ options['database-config'] = dbconfig
+
+ zeo = options.get('zeo', 'ZODB3')
+ zdaemon = options.get('zdaemon', 'ZODB3')
+ if zdaemon != zeo:
+ zeo += '\n' + zdaemon
+ options['eggs'] = zeo
+
+ options['bin-directory'] = buildout['buildout']['bin-directory']
+
+ options['zconfig'] = zeoclient_template % dict(
+ address = zeo_options['address'],
+ )
+
+ # We don't want scripts generated
+ options['scripts'] = ''
+ options.pop('entry-points', None)
+
+ # delegate to egg recipe
+ self.egg = zc.recipe.egg.Egg(buildout, name, options)
+
+ def install(self):
+ options = self.options
+ dest = options['location']
+ os.mkdir(dest)
+ conf_path = os.path.join(dest, 'zeo.conf')
+
+ # Later we'll use the deployment mechanism to get these:
+ bin_dir = options['bin-directory']
+ log_dir = dest
+ subprogram_dir = dest
+ run_dir = dest
+ user = ''
+
+ open(conf_path, 'w').write(
+ zeo_conf % dict(
+ options = self.zeo_options,
+ storage = options['database-config'],
+ log_dir = log_dir,
+ subprogram_dir = subprogram_dir,
+ run_dir = run_dir,
+ user = user,
+ executable = options['executable'],
+ ))
+
+ requirements, ws = self.egg.working_set()
+
+ zc.buildout.easy_install.scripts(
+ [('runzeo', 'ZEO.runzeo', 'main')],
+ ws, options['executable'], subprogram_dir,
+ arguments = ('\n ["-C", %r]'
+ '\n + sys.argv[1:]'
+ % conf_path),
+ )
+
+ zc.buildout.easy_install.scripts(
+ [('zdrun', 'zdaemon.zdrun', 'main')],
+ ws, options['executable'], subprogram_dir,
+ )
+
+ zc.buildout.easy_install.scripts(
+ [(self.name, 'ZEO.zeoctl', 'main')],
+ ws, options['executable'], options['bin-directory'],
+ arguments = ('\n ["-C", %r]'
+ '\n + sys.argv[1:]'
+ % conf_path),
+ )
+
+ return dest, os.path.join(bin_dir, self.name)
+
+ def update(self):
+ pass
+
+
+zeo_conf = """\
+# ZEO configuration file
+#
+# This file is generated. If you edit this file, your edits could
+# easily be lost.
+
+<zeo>
+ %(options)s
+</zeo>
+
+%(storage)s
+
+<eventlog>
+ level info
+ <logfile>
+ path %(log_dir)s/zeo.log
+ </logfile>
+</eventlog>
+
+<runner>
+ program %(subprogram_dir)s/runzeo
+ socket-name %(run_dir)s/zeo.zdsock
+ daemon true
+ forever false
+ backoff-limit 10
+ exit-codes 0, 2
+ directory %(run_dir)s
+ default-to-interactive true
+ %(user)spython %(executable)s
+ logfile %(log_dir)s/zeo.log
+</runner>
+"""
+
+zeoclient_template = """\
+<zodb>
+ <zeoclient>
+ server %(address)s
+ </zeoclient>
+</zodb>
+"""
Property changes on: zc.recipe.zeo/branches/dev/src/zc/recipe/zeo/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zc.recipe.zeo/branches/dev/src/zc/recipe/zeo/tests.py
===================================================================
--- zc.recipe.zeo/branches/dev/src/zc/recipe/zeo/tests.py 2006-10-30 11:46:21 UTC (rev 70993)
+++ zc.recipe.zeo/branches/dev/src/zc/recipe/zeo/tests.py 2006-10-30 12:10:22 UTC (rev 70994)
@@ -0,0 +1,46 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+import re
+import zc.buildout.testing
+
+import unittest
+from zope.testing import doctest, renormalizing
+
+def setUp(test):
+ zc.buildout.testing.buildoutSetUp(test)
+ zc.buildout.testing.install_develop('zc.recipe.zeo', test)
+ zc.buildout.testing.install_develop('zc.recipe.egg', test)
+ zc.buildout.testing.install('ZODB3', test)
+
+def test_suite():
+ return unittest.TestSuite((
+ #doctest.DocTestSuite(),
+ doctest.DocFileSuite(
+ 'README.txt',
+ setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown,
+ checker=renormalizing.RENormalizing([
+ zc.buildout.testing.normalize_path,
+ zc.buildout.testing.normalize_script,
+ zc.buildout.testing.normalize_egg_py,
+ (re.compile('#!\S+python\S*'), '#!python'),
+ (re.compile('setuptools-[^-]+-'), 'setuptools-X-'),
+ (re.compile('ZODB3-\S+[.]egg'), 'ZODB3.egg'),
+ (re.compile(r"\nCouldn't find index page for 'ZODB3' "
+ r"\(maybe misspelled\?\)"),
+ ''),
+ ])
+ ),
+
+ ))
Property changes on: zc.recipe.zeo/branches/dev/src/zc/recipe/zeo/tests.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
More information about the Checkins
mailing list