[Checkins] SVN: zc.zope3recipes/trunk/ Fixed bug: The zope.conf site-definition option could not be overridden.

Jim Fulton jim at zope.com
Mon Dec 17 15:27:20 EST 2007


Log message for revision 82316:
  Fixed bug: The zope.conf site-definition option could not be overridden.
  

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

-=-
Modified: zc.zope3recipes/trunk/README.txt
===================================================================
--- zc.zope3recipes/trunk/README.txt	2007-12-17 20:09:06 UTC (rev 82315)
+++ zc.zope3recipes/trunk/README.txt	2007-12-17 20:27:19 UTC (rev 82316)
@@ -14,16 +14,20 @@
 
 .. contents::
 
+Releases
+********
 
-Trunk
-*****
+==================
+0.6.1 (2007/12/17)
+==================
 
-Added windows support. Included a custom ZDCmd and a suprocess wrapper 
-in winctl.py. Now the basic commands will also work on a windows box.
+Fixed bug: The zope.conf site-definition option could not be overridden. 
 
+==================
+0.6.0 (2007/11/03)
+==================
 
-Releases
-********
+Final release with Windows support.
 
 ==================
 0.6b1 (2007/08/21)

Modified: zc.zope3recipes/trunk/zc/zope3recipes/README.txt
===================================================================
--- zc.zope3recipes/trunk/zc/zope3recipes/README.txt	2007-12-17 20:09:06 UTC (rev 82315)
+++ zc.zope3recipes/trunk/zc/zope3recipes/README.txt	2007-12-17 20:27:19 UTC (rev 82316)
@@ -1290,7 +1290,107 @@
       </logfile>
     </eventlog>
 
+Specifying an alternate site definition
+---------------------------------------
 
+Ideally, ZCML is used to configure the software used by an application
+and zope.conf is used to provide instance-specific configuration.  For
+historical reasons, there are ZCML directives that provide process
+configuration.  A good example of this is the smtpMailer directive
+provided by the zope.sendmail package.  We can override the
+site-definition option in the zope.conf file to specify an alternate
+zcml file.  Here, we'll update out instance configuration to use an
+alternate site definition:
+
+    >>> write('buildout.cfg',
+    ... '''
+    ... [buildout]
+    ... develop = demo1 demo2
+    ... parts = instance
+    ...
+    ... [zope3]
+    ... location = %(zope3)s
+    ...
+    ... [myapp]
+    ... recipe = zc.zope3recipes:app
+    ... 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 =
+    ...     site-definition ${buildout:directory}/site.zcml
+    ...     <zodb>
+    ...       <zeoclient>
+    ...         server 127.0.0.1:8001
+    ...         server 127.0.0.1:8002
+    ...       </zeoclient>
+    ...     </zodb>
+    ... address = 8081
+    ... zdaemon.conf =
+    ...     <runner>
+    ...       daemon off
+    ...       socket-name /sample-buildout/parts/instance/sock
+    ...       transcript /dev/null
+    ...     </runner>
+    ...     <eventlog>
+    ...     </eventlog>
+    ...
+    ... ''' % globals())
+
+    >>> print system(join('bin', 'buildout')),
+    Develop: '/sample-buildout/demo1'
+    Develop: '/sample-buildout/demo2'
+    Uninstalling instance.
+    Updating myapp.
+    Installing instance.
+    Generated script '/sample-buildout/bin/instance'.
+
+    >>> cat('parts', 'instance', 'zope.conf')
+    site-definition /sample-buildout/site.zcml
+    <BLANKLINE>
+    <zodb>
+      <zeoclient>
+        server 127.0.0.1:8001
+        server 127.0.0.1:8002
+      </zeoclient>
+    </zodb>
+    <BLANKLINE>
+    <server>
+      address 8081
+      type HTTP
+    </server>
+    <BLANKLINE>
+    <accesslog>
+      <logfile>
+        path /sample-buildout/parts/instance/access.log
+      </logfile>
+    </accesslog>
+    <BLANKLINE>
+    <eventlog>
+      <logfile>
+        formatter zope.exceptions.log.Formatter
+        path STDOUT
+      </logfile>
+    </eventlog>
+
+(Note that, in practice, you'll often use the
+zc.recipe.deployment:configuration recipe,
+http://pypi.python.org/pypi/zc.recipe.deployment#configuration-files,
+to define a site.zcml file using the buildout.)
+
 Log files
 ---------
 

Modified: zc.zope3recipes/trunk/zc/zope3recipes/recipes.py
===================================================================
--- zc.zope3recipes/trunk/zc/zope3recipes/recipes.py	2007-12-17 20:09:06 UTC (rev 82315)
+++ zc.zope3recipes/trunk/zc/zope3recipes/recipes.py	2007-12-17 20:27:19 UTC (rev 82316)
@@ -229,7 +229,10 @@
             zope_conf = ZConfig.schemaless.loadConfigFile(
                 cStringIO.StringIO(zope_conf))
 
-            zope_conf['site-definition'] = [os.path.join(app_loc, 'site.zcml')]
+            if 'site-definition' not in zope_conf:
+                zope_conf['site-definition'] = [
+                    os.path.join(app_loc, 'site.zcml')
+                    ]
 
             server_type = server_types[options['servers']][1]
             for address in options.get('address', '').split():



More information about the Checkins mailing list