[Checkins] SVN: zc.zope3recipes/trunk/ Use deployment name option,

Jim Fulton jim at zope.com
Fri Feb 1 10:50:27 EST 2008


Log message for revision 83388:
  Use deployment name option,
  

Changed:
  U   zc.zope3recipes/trunk/README.txt
  U   zc.zope3recipes/trunk/zc/zope3recipes/README.txt
  U   zc.zope3recipes/trunk/zc/zope3recipes/recipes.py
  U   zc.zope3recipes/trunk/zc/zope3recipes/tests.py

-=-
Modified: zc.zope3recipes/trunk/README.txt
===================================================================
--- zc.zope3recipes/trunk/README.txt	2008-02-01 15:41:54 UTC (rev 83387)
+++ zc.zope3recipes/trunk/README.txt	2008-02-01 15:50:27 UTC (rev 83388)
@@ -18,6 +18,13 @@
 ********
 
 ==================
+0.7.0 (2008/02/01)
+==================
+
+Use the deployment name option (as provided by zc.recipe.deployment
+0.6.0 and later) if present.
+
+==================
 0.6.1 (2007/12/17)
 ==================
 

Modified: zc.zope3recipes/trunk/zc/zope3recipes/README.txt
===================================================================
--- zc.zope3recipes/trunk/zc/zope3recipes/README.txt	2008-02-01 15:41:54 UTC (rev 83387)
+++ zc.zope3recipes/trunk/zc/zope3recipes/README.txt	2008-02-01 15:50:27 UTC (rev 83388)
@@ -1481,12 +1481,13 @@
     ... application = myapp
     ... zope.conf = ${database:zconfig}
     ... address = 8081
-    ... deployment = myapp-run
+    ... deployment = myapp-deployment
     ...
     ... [database]
     ... recipe = zc.recipe.filestorage
     ...
-    ... [myapp-run]
+    ... [myapp-deployment]
+    ... name = myapp-run
     ... etc-directory = %(root)s/etc/myapp-run
     ... rc-directory = %(root)s/etc/init.d
     ... log-directory = %(root)s/var/log/myapp-run
@@ -1494,7 +1495,7 @@
     ... user = zope
     ... ''' % globals())
 
-Here we've added a deployment section, myapp-run, and added a
+Here we've added a deployment section, myapp-deployment, and added a
 deployment option to our instance part telling the instance recipe to
 use the deployment.  If we rerun the buildout:
 
@@ -1622,7 +1623,7 @@
     ... application = myapp
     ... zope.conf = ${database:zconfig}
     ... address = 8081
-    ... deployment = myapp-run
+    ... deployment = myapp-deployment
     ...
     ... [instance2]
     ... recipe = zc.zope3recipes:instance
@@ -1632,7 +1633,8 @@
     ... [database]
     ... recipe = zc.recipe.filestorage
     ...
-    ... [myapp-run]
+    ... [myapp-deployment]
+    ... name = myapp-run
     ... etc-directory = %(root)s/etc/myapp-run
     ... rc-directory = %(root)s/etc/init.d
     ... log-directory = %(root)s/var/log/myapp-run

Modified: zc.zope3recipes/trunk/zc/zope3recipes/recipes.py
===================================================================
--- zc.zope3recipes/trunk/zc/zope3recipes/recipes.py	2008-02-01 15:41:54 UTC (rev 83387)
+++ zc.zope3recipes/trunk/zc/zope3recipes/recipes.py	2008-02-01 15:50:27 UTC (rev 83388)
@@ -158,6 +158,8 @@
 """
 
 class Instance:
+
+    deployment = None
     
     def __init__(self, buildout, name, options):
         self.name, self.options = name, options
@@ -176,8 +178,11 @@
         options['eggs'] = options.get('eggs', 'zdaemon\nsetuptools')
         self.egg = zc.recipe.egg.Egg(buildout, name, options)
 
-        deployment = self.deployment = options.get('deployment')
+        deployment = options.get('deployment')
         if deployment:
+            # Note we use get below to work with old zc.recipe.deployment eggs.
+            self.deployment = buildout[deployment].get('name', deployment)
+            
             options['bin-directory'] = buildout[deployment]['rc-directory']
             options['run-directory'] = buildout[deployment]['run-directory']
             options['log-directory'] = buildout[deployment]['log-directory']

Modified: zc.zope3recipes/trunk/zc/zope3recipes/tests.py
===================================================================
--- zc.zope3recipes/trunk/zc/zope3recipes/tests.py	2008-02-01 15:41:54 UTC (rev 83387)
+++ zc.zope3recipes/trunk/zc/zope3recipes/tests.py	2008-02-01 15:50:27 UTC (rev 83388)
@@ -115,6 +115,80 @@
     Error: No database sections have been defined.
     """
 
+def work_with_old_zc_deployment():
+    """
+
+    >>> mkdir('demo1')
+    >>> write('demo1', 'setup.py',
+    ... '''
+    ... from setuptools import setup
+    ... setup(name = 'demo1')
+    ... ''')
+
+    >>> mkdir('demo2')
+    >>> write('demo2', 'setup.py',
+    ... '''
+    ... from setuptools import setup
+    ... setup(name = 'demo2', install_requires='demo1')
+    ... ''')
+
+    >>> root = tmpdir('root')
+    >>> mkdir(root, 'etc')
+    >>> mkdir(root, 'etc', 'myapp-run')
+    >>> mkdir(root, 'etc', 'init.d')
+
+    >>> write('buildout.cfg',
+    ... '''
+    ... [buildout]
+    ... develop = demo1 demo2
+    ... parts = instance
+    ...
+    ... [myapp]
+    ... recipe = zc.zope3recipes:application
+    ... site.zcml = <include package="demo2" />
+    ...             <principal
+    ...                 id="zope.manager"
+    ...                 title="Manager"
+    ...                 login="jim"
+    ...                 password_manager="SHA1"
+    ...                 password="40bd001563085fc35165329ea1ff5c5ecbdbbeef"
+    ...                 />
+    ...             <grant
+    ...                 role="zope.Manager"
+    ...                 principal="zope.manager"
+    ...                 />
+    ... eggs = demo2
+    ...
+    ... [instance]
+    ... recipe = zc.zope3recipes:instance
+    ... application = myapp
+    ... zope.conf = ${database:zconfig}
+    ... address = 8081
+    ... deployment = myapp-run
+    ...
+    ... [database]
+    ... recipe = zc.recipe.filestorage
+    ...
+    ... [myapp-run]
+    ... etc-directory = %(root)s/etc/myapp-run
+    ... rc-directory = %(root)s/etc/init.d
+    ... log-directory = %(root)s/var/log/myapp-run
+    ... run-directory = %(root)s/var/run/myapp-run
+    ... user = zope
+    ... ''' % globals())
+
+    >>> print system(join('bin', 'buildout')),
+    Develop: '/sample-buildout/demo1'
+    Develop: '/sample-buildout/demo2'
+    Installing database.
+    Installing myapp.
+    Generated script '/sample-buildout/parts/myapp/runzope'.
+    Generated script '/sample-buildout/parts/myapp/debugzope'.
+    Installing instance.
+    Generated script '/root/etc/init.d/myapp-run-instance'.
+   
+    """
+
 def setUp(test):
     zc.buildout.testing.buildoutSetUp(test)
     zc.buildout.testing.install_develop('zc.zope3recipes', test)



More information about the Checkins mailing list