[Checkins] SVN: zc.zope3recipes/trunk/ Merged changes accidentilly
made in dev after dev was cpied to
Jim Fulton
jim at zope.com
Fri Mar 9 08:19:19 EST 2007
Log message for revision 73115:
Merged changes accidentilly made in dev after dev was cpied to
trunk. (I should have moved it.)
Changed:
U zc.zope3recipes/trunk/setup.py
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/setup.py
===================================================================
--- zc.zope3recipes/trunk/setup.py 2007-03-09 12:00:31 UTC (rev 73114)
+++ zc.zope3recipes/trunk/setup.py 2007-03-09 13:19:18 UTC (rev 73115)
@@ -21,7 +21,7 @@
name = "zc.zope3recipes"
setup(
name = name,
- version = "0.3",
+ version = "0.4",
author = "Jim Fulton",
author_email = "jim at zope.com",
description = "ZC Buildout recipe for defining Zope 3 applications",
Modified: zc.zope3recipes/trunk/zc/zope3recipes/README.txt
===================================================================
--- zc.zope3recipes/trunk/zc/zope3recipes/README.txt 2007-03-09 12:00:31 UTC (rev 73114)
+++ zc.zope3recipes/trunk/zc/zope3recipes/README.txt 2007-03-09 13:19:18 UTC (rev 73115)
@@ -190,6 +190,124 @@
if __name__ == '__main__':
zc.zope3recipes.debugzope.debug()
+Note that the runzope shown above uses the default, twisted-based
+server components. It's possible to specify which set of server
+components is used: the "servers" setting can be set to either
+"zserver" or "twisted". For the application, this affects the runzope
+script; we'll see additional differences when we create instances of
+the application.
+
+Let's continue to use the twisted servers, but make the selection
+explicit:
+
+ >>> write('buildout.cfg',
+ ... '''
+ ... [buildout]
+ ... develop = demo1 demo2
+ ... parts = myapp
+ ...
+ ... [zope3]
+ ... location = %(zope3)s
+ ...
+ ... [myapp]
+ ... recipe = zc.zope3recipes:app
+ ... servers = twisted
+ ... 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
+ ... ''' % globals())
+
+ >>> print system(join('bin', 'buildout')),
+ buildout: Develop: /sample-buildout/demo1
+ buildout: Develop: /sample-buildout/demo2
+ buildout: Updating myapp
+
+Note that this is recognized as not being a change to the
+configuration; the messages say that myapp was updated, not
+uninstalled and then re-installed.
+
+The runzope script generated is identical to what we saw before:
+
+ >>> cat('parts', 'myapp', 'runzope')
+ #!/usr/local/bin/python2.4
+ <BLANKLINE>
+ import sys
+ sys.path[0:0] = [
+ '/sample-buildout/demo2',
+ '/sample-buildout/demo1',
+ '/zope3/src',
+ ]
+ <BLANKLINE>
+ import zope.app.twisted.main
+ <BLANKLINE>
+ if __name__ == '__main__':
+ zope.app.twisted.main.main()
+
+We can also specify the ZServer servers explicitly:
+
+ >>> write('buildout.cfg',
+ ... '''
+ ... [buildout]
+ ... develop = demo1 demo2
+ ... parts = myapp
+ ...
+ ... [zope3]
+ ... location = %(zope3)s
+ ...
+ ... [myapp]
+ ... recipe = zc.zope3recipes:app
+ ... servers = zserver
+ ... 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
+ ... ''' % globals())
+
+ >>> print system(join('bin', 'buildout')),
+ buildout: Develop: /sample-buildout/demo1
+ buildout: Develop: /sample-buildout/demo2
+ buildout: Uninstalling myapp
+ buildout: Installing myapp
+
+The part has been re-installed, and the runzope script generated is
+different now. Note that the main() function is imported from a
+different package this time:
+
+ >>> cat('parts', 'myapp', 'runzope')
+ #!/usr/local/bin/python2.4
+ <BLANKLINE>
+ import sys
+ sys.path[0:0] = [
+ '/sample-buildout/demo2',
+ '/sample-buildout/demo1',
+ '/zope3/src',
+ ]
+ <BLANKLINE>
+ import zope.app.server.main
+ <BLANKLINE>
+ if __name__ == '__main__':
+ zope.app.server.main.main()
+
+
Legacy Functional Testing Support
---------------------------------
@@ -446,6 +564,166 @@
<BLANKLINE>
</eventlog>
+This uses the twisted server types, since that's the default
+configuration for Zope 3. If we specify use of the ZServer servers,
+the names of the server types are adjusted appropriately:
+
+ >>> write('buildout.cfg',
+ ... '''
+ ... [buildout]
+ ... develop = demo1 demo2
+ ... parts = instance
+ ...
+ ... [zope3]
+ ... location = %(zope3)s
+ ...
+ ... [myapp]
+ ... recipe = zc.zope3recipes:app
+ ... servers = zserver
+ ... 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}
+ ...
+ ... [database]
+ ... recipe = zc.recipe.filestorage
+ ... ''' % globals())
+
+ >>> print system(join('bin', 'buildout')),
+ buildout: Develop: /sample-buildout/demo1
+ buildout: Develop: /sample-buildout/demo2
+ buildout: Uninstalling instance
+ buildout: Uninstalling myapp
+ buildout: Updating database
+ buildout: Installing myapp
+ buildout: Installing instance
+
+The generated zope.conf file now uses the ZServer server components
+instead:
+
+ >>> cat('parts', 'instance', 'zope.conf')
+ site-definition /sample-buildout/parts/myapp/site.zcml
+ <BLANKLINE>
+ <zodb>
+ <filestorage>
+ path /sample-buildout/parts/database/Data.fs
+ </filestorage>
+ <BLANKLINE>
+ </zodb>
+ <BLANKLINE>
+ <server>
+ address 8080
+ type WSGI-HTTP
+ </server>
+ <BLANKLINE>
+ <accesslog>
+ <logfile>
+ path /sample-buildout/parts/instance/access.log
+ </logfile>
+ <BLANKLINE>
+ </accesslog>
+ <BLANKLINE>
+ <eventlog>
+ <logfile>
+ formatter zope.exceptions.log.Formatter
+ path STDOUT
+ </logfile>
+ <BLANKLINE>
+ </eventlog>
+
+The Twisted-based servers can also be specified explicitly:
+
+ >>> write('buildout.cfg',
+ ... '''
+ ... [buildout]
+ ... develop = demo1 demo2
+ ... parts = instance
+ ...
+ ... [zope3]
+ ... location = %(zope3)s
+ ...
+ ... [myapp]
+ ... recipe = zc.zope3recipes:app
+ ... servers = twisted
+ ... 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}
+ ...
+ ... [database]
+ ... recipe = zc.recipe.filestorage
+ ... ''' % globals())
+
+ >>> print system(join('bin', 'buildout')),
+ buildout: Develop: /sample-buildout/demo1
+ buildout: Develop: /sample-buildout/demo2
+ buildout: Uninstalling instance
+ buildout: Uninstalling myapp
+ buildout: Updating database
+ buildout: Installing myapp
+ buildout: Installing instance
+
+The generated zope.conf file now uses the Twisted server components
+once more:
+
+ >>> cat('parts', 'instance', 'zope.conf')
+ site-definition /sample-buildout/parts/myapp/site.zcml
+ <BLANKLINE>
+ <zodb>
+ <filestorage>
+ path /sample-buildout/parts/database/Data.fs
+ </filestorage>
+ <BLANKLINE>
+ </zodb>
+ <BLANKLINE>
+ <server>
+ address 8080
+ type HTTP
+ </server>
+ <BLANKLINE>
+ <accesslog>
+ <logfile>
+ path /sample-buildout/parts/instance/access.log
+ </logfile>
+ <BLANKLINE>
+ </accesslog>
+ <BLANKLINE>
+ <eventlog>
+ <logfile>
+ formatter zope.exceptions.log.Formatter
+ path STDOUT
+ </logfile>
+ <BLANKLINE>
+ </eventlog>
+
It includes the database definition that we provided in the zope.conf
option. It has a site-definition option that names the site.zcml file
from our application directory.
Modified: zc.zope3recipes/trunk/zc/zope3recipes/recipes.py
===================================================================
--- zc.zope3recipes/trunk/zc/zope3recipes/recipes.py 2007-03-09 12:00:31 UTC (rev 73114)
+++ zc.zope3recipes/trunk/zc/zope3recipes/recipes.py 2007-03-09 13:19:18 UTC (rev 73115)
@@ -24,6 +24,13 @@
this_loc = pkg_resources.working_set.find(
pkg_resources.Requirement.parse('zc.zope3recipes')).location
+server_types = {
+ # name (module, http-name)
+ 'twisted': ('zope.app.twisted.main', 'HTTP'),
+ 'zserver': ('zope.app.server.main', 'WSGI-HTTP'),
+ }
+
+
class App:
def __init__(self, buildout, name, options):
@@ -39,10 +46,14 @@
buildout[options.get('zope3', 'zope3')]['location'],
)
+ options['servers'] = options.get('servers', 'twisted')
+ if options['servers'] not in server_types:
+ raise ValueError(
+ 'servers setting must be one of "twisted" or "zserver"')
+
options['scripts'] = ''
self.egg = zc.recipe.egg.Egg(buildout, name, options)
-
def install(self):
options = self.options
@@ -84,8 +95,9 @@
requirements, ws = self.egg.working_set()
# install subprograms and ctl scripts
+ server_module = server_types[options['servers']][0]
zc.buildout.easy_install.scripts(
- [('runzope', 'zope.app.twisted.main', 'main')],
+ [('runzope', server_module, 'main')],
ws, options['executable'], dest,
extra_paths = options['extra-paths'].split(),
)
@@ -139,6 +151,7 @@
]['location']
options['scripts'] = ''
+ options['servers'] = buildout[options['application']]['servers']
options['eggs'] = options.get('eggs', 'zdaemon\nsetuptools')
self.egg = zc.recipe.egg.Egg(buildout, name, options)
@@ -196,10 +209,11 @@
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():
zope_conf.sections.append(
ZConfigSection('server',
- data=dict(type='HTTP',
+ data=dict(type=server_type,
address=address,
),
)
@@ -208,7 +222,7 @@
if ('server' in s.type)]:
zope_conf.sections.append(
ZConfigSection('server',
- data=dict(type='HTTP',
+ data=dict(type=server_type,
address='8080',
),
)
Modified: zc.zope3recipes/trunk/zc/zope3recipes/tests.py
===================================================================
--- zc.zope3recipes/trunk/zc/zope3recipes/tests.py 2007-03-09 12:00:31 UTC (rev 73114)
+++ zc.zope3recipes/trunk/zc/zope3recipes/tests.py 2007-03-09 13:19:18 UTC (rev 73115)
@@ -96,6 +96,9 @@
...
... [myapp]
... location = foo
+ ... ;; Note that 'servers' has a default value when the
+ ... ;; application recipe is involved.
+ ... servers = twisted
...
... [instance]
... recipe = zc.zope3recipes:instance
More information about the Checkins
mailing list