From: Hanno S. <svn...@pl...> - 2008-11-18 21:57:42
|
Author: hannosch Date: Tue Nov 18 21:57:38 2008 New Revision: 76063 Added: buildout/plone.recipe.zope2instance/trunk/src/plone/recipe/zope2instance/simple.py (contents, props changed) Modified: buildout/plone.recipe.zope2instance/trunk/CHANGES.txt buildout/plone.recipe.zope2instance/trunk/src/plone/recipe/zope2instance/__init__.py Log: Added a `zope2-egg` option and an accompanying simple startup script for use with an eggified Zope2. Modified: buildout/plone.recipe.zope2instance/trunk/CHANGES.txt ============================================================================== --- buildout/plone.recipe.zope2instance/trunk/CHANGES.txt (original) +++ buildout/plone.recipe.zope2instance/trunk/CHANGES.txt Tue Nov 18 21:57:38 2008 @@ -4,6 +4,10 @@ 2.7 (Unreleased) ---------------- +- Added a `zope2-egg` option and an accompanying simple startup script for + use with an eggified Zope2. + [hannosch] + - Do not fail with a Zope2 egg checkout. [hannosch] Modified: buildout/plone.recipe.zope2instance/trunk/src/plone/recipe/zope2instance/__init__.py ============================================================================== --- buildout/plone.recipe.zope2instance/trunk/src/plone/recipe/zope2instance/__init__.py (original) +++ buildout/plone.recipe.zope2instance/trunk/src/plone/recipe/zope2instance/__init__.py Tue Nov 18 21:57:38 2008 @@ -22,6 +22,7 @@ def __init__(self, buildout, name, options): self.egg = zc.recipe.egg.Egg(buildout, options['recipe'], options) self.buildout, self.options, self.name = buildout, options, name + self.zope2_egg = options.get('zope2-egg', False) options['location'] = os.path.join( buildout['buildout']['parts-directory'], @@ -420,6 +421,9 @@ fd.close() def patch_binaries(self, ws_locations): + if self.zope2_egg: + return + location = self.options['location'] path =":".join(ws_locations) for script_name in ('runzope', 'zopectl'): @@ -522,29 +526,40 @@ requirements, ws = self.egg.working_set(['plone.recipe.zope2instance']) - zc.buildout.easy_install.scripts( - [(self.options.get('control-script', self.name), - 'plone.recipe.zope2instance.ctl', 'main')], - ws, options['executable'], options['bin-directory'], - extra_paths = extra_paths, - arguments = ('\n ["-C", %r]' - '\n + sys.argv[1:]' - % zope_conf - ), - ) - # The backup script, pointing to repozo.py - repozo = options.get('repozo', None) - if repozo is None: - repozo = os.path.join(options['zope2-location'], 'utilities', 'ZODBTools', 'repozo.py') - - directory, filename = os.path.split(repozo) - if repozo and os.path.exists(repozo): + if self.zope2_egg: zc.buildout.easy_install.scripts( - [('repozo', os.path.splitext(filename)[0], 'main')], - {}, options['executable'], options['bin-directory'], - extra_paths = [os.path.join(options['zope2-location'], 'lib', 'python'), - directory], + [(self.options.get('control-script', self.name), + 'plone.recipe.zope2instance.simple', 'main')], + ws, options['executable'], options['bin-directory'], + extra_paths = extra_paths, + arguments = ('\n [%r]' + % zope_conf + ), ) + else: + zc.buildout.easy_install.scripts( + [(self.options.get('control-script', self.name), + 'plone.recipe.zope2instance.ctl', 'main')], + ws, options['executable'], options['bin-directory'], + extra_paths = extra_paths, + arguments = ('\n ["-C", %r]' + '\n + sys.argv[1:]' + % zope_conf + ), + ) + # The backup script, pointing to repozo.py + repozo = options.get('repozo', None) + if repozo is None: + repozo = os.path.join(options['zope2-location'], 'utilities', 'ZODBTools', 'repozo.py') + + directory, filename = os.path.split(repozo) + if repozo and os.path.exists(repozo): + zc.buildout.easy_install.scripts( + [('repozo', os.path.splitext(filename)[0], 'main')], + {}, options['executable'], options['bin-directory'], + extra_paths = [os.path.join(options['zope2-location'], 'lib', 'python'), + directory], + ) def build_package_includes(self): """Create ZCML slugs in etc/package-includes Added: buildout/plone.recipe.zope2instance/trunk/src/plone/recipe/zope2instance/simple.py ============================================================================== --- (empty file) +++ buildout/plone.recipe.zope2instance/trunk/src/plone/recipe/zope2instance/simple.py Tue Nov 18 21:57:38 2008 @@ -0,0 +1,16 @@ +import os + +def main(args=None): + """ Start a Zope instance """ + import Zope2.Startup + + if args is None: + return + + configfile = args[0] + + starter = Zope2.Startup.get_starter() + opts = Zope2.Startup.run._setconfig(configfile=configfile) + starter.setConfiguration(opts.configroot) + starter.prepare() + starter.run() |