[Checkins] SVN: zc.zope3recipes/trunk/ - Merge from baijum-app-from-eggs branch:

Baiju M baiju.m.mail at gmail.com
Wed Mar 21 04:42:46 EDT 2007


Log message for revision 73412:
   - Merge from baijum-app-from-eggs branch:
  
      Support building Zope 3 application solely from eggs.
      Ref: http://mail.zope.org/pipermail/zope3-dev/2007-March/022009.html
  
   - Prepare for 0.5.0 release
  

Changed:
  U   zc.zope3recipes/trunk/README.txt
  A   zc.zope3recipes/trunk/bootstrap.py
  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/README.txt
===================================================================
--- zc.zope3recipes/trunk/README.txt	2007-03-21 08:16:20 UTC (rev 73411)
+++ zc.zope3recipes/trunk/README.txt	2007-03-21 08:42:45 UTC (rev 73412)
@@ -12,3 +12,12 @@
 - Don't support package-includes
 
 .. contents::
+
+Releases
+********
+
+==================
+0.5.0 (2007/03/21)
+==================
+
+Support building Zope 3 application solely from eggs.

Added: zc.zope3recipes/trunk/bootstrap.py
===================================================================
--- zc.zope3recipes/trunk/bootstrap.py	2007-03-21 08:16:20 UTC (rev 73411)
+++ zc.zope3recipes/trunk/bootstrap.py	2007-03-21 08:42:45 UTC (rev 73412)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+ez = {}
+exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+                     ).read() in ez
+ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+    cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+    os.P_WAIT, sys.executable, sys.executable,
+    '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+    dict(os.environ,
+         PYTHONPATH=
+         ws.find(pkg_resources.Requirement.parse('setuptools')).location
+         ),
+    ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)


Property changes on: zc.zope3recipes/trunk/bootstrap.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: zc.zope3recipes/trunk/setup.py
===================================================================
--- zc.zope3recipes/trunk/setup.py	2007-03-21 08:16:20 UTC (rev 73411)
+++ zc.zope3recipes/trunk/setup.py	2007-03-21 08:42:45 UTC (rev 73412)
@@ -16,12 +16,12 @@
     '**********************\n'
     )
 
-open('long-description.txt', 'w').write(long_description)
+#open('long-description.txt', 'w').write(long_description)
 
 name = "zc.zope3recipes"
 setup(
     name = name,
-    version = "0.4",
+    version = "0.5.0",
     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-21 08:16:20 UTC (rev 73411)
+++ zc.zope3recipes/trunk/zc/zope3recipes/README.txt	2007-03-21 08:42:45 UTC (rev 73412)
@@ -12,14 +12,13 @@
 ============================
 
 The "app" recipe is used to define a Zope application.  It is designed
-to work with classic Zope releases. (In the future, there will be an
-"application" recipe that will work with Zope soley as eggs.)  The app
-recipe causes a part to be created. The part will contain the scripts
-runzope and debugzope and the application's site.zcml.  Both of the
-scripts will require providing a -C option and the path to a zope.conf
-file when run.  The debugzope script can be run with a script name and
-arguments, in which case it will run the script, rather than starting
-an interactive session.
+to work with classic Zope releases and with Zope solely as eggs.
+The app recipe causes a part to be created. The part will contain the
+scripts runzope and debugzope and the application's site.zcml.
+Both of the scripts will require providing a -C option and the path to a
+zope.conf file when run.  The debugzope script can be run with a script
+name and arguments, in which case it will run the script, rather than
+starting an interactive session.
 
 The app recipe accepts the following options:
 
@@ -27,16 +26,17 @@
   The name of a section defining a location option that gives the
   location of a Zope installation.  This can be either a checkout or a
   distribution.  If the location has a lib/python subdirectory, it is
-  treated as a distribution, othwerwise, it must have a src
+  treated as a distribution, otherwise, it must have a src
   subdirectory and will be treated as a checkout. This option defaults
-  to "zope3".
+  to "zope3".  And if location is empty, the application will run solely
+  from eggs.
 
 site.zcml
   The contents of site.zcml.
 
 eggs
   The names of one or more eggs, with their dependencies that should
-  be included in the Python path of the generated scripts. 
+  be included in the Python path of the generated scripts.
 
 Let's look at an example.  We'll make a faux zope installation:
 
@@ -47,14 +47,14 @@
 application:
 
     >>> mkdir('demo1')
-    >>> write('demo1', 'setup.py', 
+    >>> write('demo1', 'setup.py',
     ... '''
     ... from setuptools import setup
     ... setup(name = 'demo1')
     ... ''')
 
     >>> mkdir('demo2')
-    >>> write('demo2', 'setup.py', 
+    >>> write('demo2', 'setup.py',
     ... '''
     ... from setuptools import setup
     ... setup(name = 'demo2', install_requires='demo1')
@@ -68,7 +68,7 @@
     ... [buildout]
     ... develop = demo1 demo2
     ... parts = myapp
-    ... 
+    ...
     ... [zope3]
     ... location = %(zope3)s
     ...
@@ -90,7 +90,7 @@
     ... ''' % globals())
 
 Note that our site.zcml file is very small.  It expect the application
-zcml to define amost everything.  In fact, a site.zcml file will often
+zcml to define almost everything.  In fact, a site.zcml file will often
 include just a single include directive.  We don't need to include the
 surrounding configure element, unless we want a namespace other than
 the zope namespace.  A configure directive will be included for us.
@@ -157,7 +157,7 @@
 It includes in it's path the eggs we specified in the configuration
 file, along with their dependencies. Note that we haven't specified a
 configuration file.  When runzope is run, a -C option must be used to
-provide a configuration file.  -X options can also be provided to 
+provide a configuration file.  -X options can also be provided to
 override configuration file options.
 
 The debugzope script provides access to the object system.  When
@@ -205,7 +205,7 @@
     ... [buildout]
     ... develop = demo1 demo2
     ... parts = myapp
-    ... 
+    ...
     ... [zope3]
     ... location = %(zope3)s
     ...
@@ -260,7 +260,7 @@
     ... [buildout]
     ... develop = demo1 demo2
     ... parts = myapp
-    ... 
+    ...
     ... [zope3]
     ... location = %(zope3)s
     ...
@@ -308,12 +308,88 @@
         zope.app.server.main.main()
 
 
+Run Application Solely from Eggs
+--------------------------------
+
+To run a Zope 3 application solely from eggs, value of location in
+zope3 section should be set to empty.  Now we'll create a buildout.cfg
+file that defines our application with an empty location for zope3:
+
+    >>> write('buildout.cfg',
+    ... '''
+    ... [buildout]
+    ... develop = demo1 demo2
+    ... parts = myapp
+    ...
+    ... [zope3]
+    ... location =
+    ...
+    ... [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
+    ... ''' % globals())
+
+Now, Let's run the buildout and see what we get:
+
+    >>> print system(join('bin', 'buildout')),
+    buildout: Develop: /sample-buildout/demo1
+    buildout: Develop: /sample-buildout/demo2
+    buildout: Uninstalling myapp
+    buildout: Installing myapp
+
+The runzope script runs the Web server:
+
+    >>> cat('parts', 'myapp', 'runzope')
+    #!/usr/local/bin/python2.4
+    <BLANKLINE>
+    import sys
+    sys.path[0:0] = [
+      '/sample-buildout/demo2',
+      '/sample-buildout/demo1',
+      ]
+    <BLANKLINE>
+    import zope.app.twisted.main
+    <BLANKLINE>
+    if __name__ == '__main__':
+        zope.app.twisted.main.main()
+
+Here, unlike the above example the location path is not included
+in sys.path .  Similarly debugzope script is also changed:
+
+    >>> cat('parts', 'myapp', 'debugzope')
+    #!/usr/local/bin/python2.4
+    <BLANKLINE>
+    import sys
+    sys.path[0:0] = [
+      '/sample-buildout/demo2',
+      '/sample-buildout/demo1',
+      '/zope3recipes',
+      ]
+    <BLANKLINE>
+    import zc.zope3recipes.debugzope
+    <BLANKLINE>
+    if __name__ == '__main__':
+        zc.zope3recipes.debugzope.debug()
+
+
 Legacy Functional Testing Support
 ---------------------------------
 
 Zope 3's functional testing support is based on zope.testing test
 layers. There is a default functional test layer that older functional
-tests use.  This layer loads the default configueration for the Zope
+tests use.  This layer loads the default configuration for the Zope
 application server.  It exists to provide support for older functional
 tests that were written before layers were added to the testing
 infrastructure.   The default testing layer has a number of
@@ -321,7 +397,7 @@
 
 - It loads configurations for a large number of packages.  This has
   the potential to introduce testing dependency on all of these
-  packages. 
+  packages.
 
 - It required a ftesting.zcml file and makes assumptions about where
   that file is.  In particular, it assumes a location relative to the
@@ -333,7 +409,7 @@
 To support older packages that use the default layer, a ftesting.zcml
 option is provided.  If it is used, then the contents of the option
 are written to a ftesting.zcml file in the application.  In addition,
-an ftesting-base.zcml file is written that includes configuration 
+an ftesting-base.zcml file is written that includes configuration
 traditionally found in a Zope 3 ftesting-base.zcml excluding reference
 to package-includes.
 
@@ -344,7 +420,7 @@
     ... [buildout]
     ... develop = demo1 demo2
     ... parts = myapp
-    ... 
+    ...
     ... [zope3]
     ... location = %(zope3)s
     ...
@@ -461,7 +537,7 @@
     ... [buildout]
     ... develop = demo1 demo2
     ... parts = instance
-    ... 
+    ...
     ... [zope3]
     ... location = %(zope3)s
     ...
@@ -516,7 +592,7 @@
     buildout: Installing myapp
     buildout: Installing instance
 
-We see thatthe database and myapp parts were included by virtue of
+We see that the database and myapp parts were included by virtue of
 being referenced from the instance part.
 
 We get new directories for our database and instance:
@@ -573,7 +649,7 @@
     ... [buildout]
     ... develop = demo1 demo2
     ... parts = instance
-    ... 
+    ...
     ... [zope3]
     ... location = %(zope3)s
     ...
@@ -652,7 +728,7 @@
     ... [buildout]
     ... develop = demo1 demo2
     ... parts = instance
-    ... 
+    ...
     ... [zope3]
     ... location = %(zope3)s
     ...
@@ -729,7 +805,7 @@
 from our application directory.
 
 We didn't specify any server or logging ZConfig sections, so some were
-generated for us.  
+generated for us.
 
 Note that, by default, the event-log output goes to standard output.
 We'll say more about that when we talk about the zdaemon
@@ -742,7 +818,7 @@
     ... [buildout]
     ... develop = demo1 demo2
     ... parts = instance
-    ... 
+    ...
     ... [zope3]
     ... location = %(zope3)s
     ...
@@ -824,7 +900,7 @@
     ... [buildout]
     ... develop = demo1 demo2
     ... parts = instance
-    ... 
+    ...
     ... [zope3]
     ... location = %(zope3)s
     ...
@@ -906,7 +982,7 @@
     ... [buildout]
     ... develop = demo1 demo2
     ... parts = instance
-    ... 
+    ...
     ... [zope3]
     ... location = %(zope3)s
     ...
@@ -981,7 +1057,7 @@
 
 Let's look at the zdaemon.conf file:
 
-    >>> cat('parts', 'instance', 'zdaemon.conf') 
+    >>> cat('parts', 'instance', 'zdaemon.conf')
     <runner>
       daemon on
       directory /sample-buildout/parts/instance
@@ -1002,7 +1078,7 @@
 file, used for communication between the zdaemon command-line script
 and the zademon manager is placed in the instance directory.
 
-If you want to overrise any part of the generated zdaemon output,
+If you want to override any part of the generated zdaemon output,
 simply provide a zdaemon.conf option in your instance section:
 
 
@@ -1011,7 +1087,7 @@
     ... [buildout]
     ... develop = demo1 demo2
     ... parts = instance
-    ... 
+    ...
     ... [zope3]
     ... location = %(zope3)s
     ...
@@ -1036,7 +1112,7 @@
     ... application = myapp
     ... zope.conf = ${database:zconfig}
     ... address = 8081
-    ... zdaemon.conf = 
+    ... zdaemon.conf =
     ...     <runner>
     ...       daemon off
     ...       socket-name /sample-buildout/parts/instance/sock
@@ -1106,10 +1182,10 @@
 only captures output from logging calls.  In particular, it doesn't
 capture startup errors written to standard error.  The zdaemon
 transcript log is very useful for capturing this output.  Without it,
-error written to standard error are lost when running as a deamon.
+error written to standard error are lost when running as a daemon.
 The default Zope 3 configuration in the past was to write the Zope
 access and event log output to both files and standard output and to
-define a transcript log.  This had the effect that the transacript
+define a transcript log.  This had the effect that the transcript
 duplicated the contents of the event log and access logs, in addition
 to capturing other output.  This was space inefficient.
 
@@ -1117,7 +1193,7 @@
 information as well as Zope error output into a single log file.  We
 do this by directing Zope's event log to standard output, where it is
 useful when running Zope in foreground mode and where it can be
-captured by the zdaemon transscript log.
+captured by the zdaemon transcript log.
 
 Unix Deployments
 ----------------
@@ -1127,9 +1203,9 @@
 options used by the instance recipe:
 
 etc-directory
-    The name of the directory where configurtion files should be
+    The name of the directory where configuration files should be
     placed.  This defaults to /etc/NAME, where NAME is the deployment
-    name. 
+    name.
 
 log-directory
     The name of the directory where application instances should write
@@ -1164,7 +1240,7 @@
     ... [buildout]
     ... develop = demo1 demo2
     ... parts = instance
-    ... 
+    ...
     ... [zope3]
     ... location = %(zope3)s
     ...
@@ -1214,7 +1290,7 @@
     buildout: Updating myapp
     buildout: Installing instance
 
-The installe files will move.  We'll no-longer have the instance part:
+The installer files will move.  We'll no-longer have the instance part:
 
     >>> ls('parts')
     d  database
@@ -1308,7 +1384,7 @@
     ... [buildout]
     ... develop = demo1 demo2
     ... parts = instance instance2
-    ... 
+    ...
     ... [zope3]
     ... location = %(zope3)s
     ...

Modified: zc.zope3recipes/trunk/zc/zope3recipes/recipes.py
===================================================================
--- zc.zope3recipes/trunk/zc/zope3recipes/recipes.py	2007-03-21 08:16:20 UTC (rev 73411)
+++ zc.zope3recipes/trunk/zc/zope3recipes/recipes.py	2007-03-21 08:42:45 UTC (rev 73412)
@@ -41,10 +41,12 @@
             self.name,
             )
 
-        options['zope3-location'] = os.path.join(
-            buildout['buildout']['directory'],
-            buildout[options.get('zope3', 'zope3')]['location'],
-            )
+        location = buildout[options.get('zope3', 'zope3')]['location']
+        if location:
+            options['zope3-location'] = os.path.join(
+                buildout['buildout']['directory'],
+                location,
+                )
 
         options['servers'] = options.get('servers', 'twisted')
         if options['servers'] not in server_types:
@@ -57,20 +59,24 @@
     def install(self):
         options = self.options
 
-        z3path = options['zope3-location']
-        if not os.path.exists(z3path):
-            logger.error("The directory, %r, doesn't exist." % z3path)
-            raise zc.buildout.UserError("No directory:", z3path)
+        try:
+            z3path = options['zope3-location']
+        except KeyError:
+            path = ''
+        else:
+            if not os.path.exists(z3path):
+                logger.error("The directory, %r, doesn't exist." % z3path)
+                raise zc.buildout.UserError("No directory:", z3path)
 
-        path = os.path.join(z3path, 'lib', 'python')
-        if not os.path.exists(path):
-            path = os.path.join(z3path, 'src')
+            path = os.path.join(z3path, 'lib', 'python')
             if not os.path.exists(path):
-                logger.error(
-                    "The directory, %r, isn't a valid checkout or release."
-                    % z3)
-                raise zc.buildout.UserError(
-                    "Invalid Zope 3 installation:", z3path)
+                path = os.path.join(z3path, 'src')
+                if not os.path.exists(path):
+                    logger.error(
+                        "The directory, %r, isn't a valid checkout or release."
+                        % z3)
+                    raise zc.buildout.UserError(
+                        "Invalid Zope 3 installation:", z3path)
 
         dest = options['location']
         if not os.path.exists(dest):

Modified: zc.zope3recipes/trunk/zc/zope3recipes/tests.py
===================================================================
--- zc.zope3recipes/trunk/zc/zope3recipes/tests.py	2007-03-21 08:16:20 UTC (rev 73411)
+++ zc.zope3recipes/trunk/zc/zope3recipes/tests.py	2007-03-21 08:42:45 UTC (rev 73412)
@@ -109,6 +109,8 @@
     >>> print system(join('bin', 'buildout')),
     Couldn't find index page for 'zc.recipe.egg' (maybe misspelled?)
     buildout: Installing instance
+    While:
+      Installing instance
     Error: No database sections have been defined.
     """
 



More information about the Checkins mailing list