[Repoze-checkins] r756 - in repoze.zope2/trunk: . repoze/zope2 repoze/zope2/etc

Chris McDonough chrism at agendaless.com
Sat Mar 1 10:03:48 UTC 2008


Author: Chris McDonough <chrism at agendaless.com>
Date: Sat Mar  1 05:03:47 2008
New Revision: 756

Log:
Allow for better specification of ZEO vs. non-ZEO via instance creation.



Added:
   repoze.zope2/trunk/repoze/zope2/etc/apache2.conf
   repoze.zope2/trunk/repoze/zope2/etc/site.zcml
   repoze.zope2/trunk/repoze/zope2/etc/zeo.conf
   repoze.zope2/trunk/repoze/zope2/etc/zope-zeoclient.conf
   repoze.zope2/trunk/repoze/zope2/etc/zope.conf
   repoze.zope2/trunk/repoze/zope2/etc/zope2.ini
   repoze.zope2/trunk/repoze/zope2/etc/zope2.wsgi
Removed:
   repoze.zope2/trunk/repoze/zope2/etc/sample-apache2.conf
   repoze.zope2/trunk/repoze/zope2/etc/sample-site.zcml
   repoze.zope2/trunk/repoze/zope2/etc/sample-zeo.conf
   repoze.zope2/trunk/repoze/zope2/etc/sample-zope.conf
   repoze.zope2/trunk/repoze/zope2/etc/sample-zope2.ini
   repoze.zope2/trunk/repoze/zope2/etc/sample-zope2.wsgi
Modified:
   repoze.zope2/trunk/CHANGES.txt
   repoze.zope2/trunk/README.txt
   repoze.zope2/trunk/repoze/zope2/instance.py
   repoze.zope2/trunk/setup.py

Modified: repoze.zope2/trunk/CHANGES.txt
==============================================================================
--- repoze.zope2/trunk/CHANGES.txt	(original)
+++ repoze.zope2/trunk/CHANGES.txt	Sat Mar  1 05:03:47 2008
@@ -1,4 +1,4 @@
-Next release
+0.3.1
 
   - mkzope2instance now:
 
@@ -6,8 +6,17 @@
 
     o writes out a zeo.conf into "etc"
 
+    o takes no arguments, only options.  '-d' replaces the single
+      argument path.
+
+    o allows the specification of 'zeo-port' (-z), 'directory' (-d)
+      (replaces single-argument instancedir), and 'http-port' (-p)
+      options.
+
   - Add a sample <zodb_db main> section to the generated zope.conf
-    that can be uncommented if using ZEO is desirable.
+    that can be uncommented if the installer wants to use ZEO instead
+    of FileStorage.  Do the inverse if the zope-zeoclient.conf file is
+    the default (if -z).
     
 0.3.0
 

Modified: repoze.zope2/trunk/README.txt
==============================================================================
--- repoze.zope2/trunk/README.txt	(original)
+++ repoze.zope2/trunk/README.txt	Sat Mar  1 05:03:47 2008
@@ -35,7 +35,7 @@
   you can finally create "instance" files (config files) within the
   sandbox by running "mk2zope2instance"::
 
-    /path/to/sandbox/bin/mkzope2instance .
+    /path/to/sandbox/bin/mkzope2instance
 
   After these steps have been performed, here's what has happened::
 

Added: repoze.zope2/trunk/repoze/zope2/etc/apache2.conf
==============================================================================
--- (empty file)
+++ repoze.zope2/trunk/repoze/zope2/etc/apache2.conf	Sat Mar  1 05:03:47 2008
@@ -0,0 +1,11 @@
+WSGIPythonHome ${sandbox}
+WSGIDaemonProcess tmp threads=1 processes=4 maximum-requests=10000 python-path=${sandbox}/lib/python2.4/site-packages
+
+<VirtualHost *:80>
+  ServerName my.machine.local
+  WSGIScriptAlias /site ${sandbox}/bin/zope2.wsgi
+  WSGIProcessGroup tmp
+  WSGIPassAuthorization On
+  SetEnv HTTP_X_VHM_HOST http://my.machine.local/site
+  SetEnv PASTE_CONFIG ${sandbox}/etc/zope2.ini
+</VirtualHost>

Added: repoze.zope2/trunk/repoze/zope2/etc/site.zcml
==============================================================================
--- (empty file)
+++ repoze.zope2/trunk/repoze/zope2/etc/site.zcml	Sat Mar  1 05:03:47 2008
@@ -0,0 +1,25 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+	       xmlns:meta="http://namespaces.zope.org/meta"
+           xmlns:five="http://namespaces.zope.org/five">
+
+  <include package="Products.Five" />
+  <meta:redefinePermission from="zope2.Public" to="zope.Public" />
+
+
+  <!-- Load the meta -->
+  <include files="package-includes/*-meta.zcml" />
+  <five:loadProducts file="meta.zcml"/>
+
+  <!-- Load the configuration -->
+  <include files="package-includes/*-configure.zcml" />
+  <five:loadProducts />
+
+  <!-- Load the configuration overrides-->
+  <includeOverrides files="package-includes/*-overrides.zcml" />
+  <five:loadProductsOverrides />
+
+
+  <securityPolicy
+      component="Products.Five.security.FiveSecurityPolicy" />
+
+</configure>

Added: repoze.zope2/trunk/repoze/zope2/etc/zeo.conf
==============================================================================
--- (empty file)
+++ repoze.zope2/trunk/repoze/zope2/etc/zeo.conf	Sat Mar  1 05:03:47 2008
@@ -0,0 +1,40 @@
+# Repoze ZEO configuration file
+
+%define INSTANCE ${sandbox}
+
+<zeo>
+  address ${zeo_port}
+  read-only false
+  invalidation-queue-size 100
+  pid-filename $INSTANCE/var/ZEO.pid
+  # monitor-address PORT
+  # transaction-timeout SECONDS
+</zeo>
+
+<filestorage 1>
+  path $INSTANCE/var/Data.fs
+</filestorage>
+
+<eventlog>
+  level info
+  <logfile>
+    path $INSTANCE/log/zeo.log
+  </logfile>
+</eventlog>
+
+<runner>
+  program $INSTANCE/bin/runzeo
+  socket-name $INSTANCE/var/zeo.zdsock
+  daemon true
+  forever false
+  backoff-limit 10
+  exit-codes 0, 2
+  directory $INSTANCE
+  default-to-interactive true
+  # user zope
+  python ${python}
+  zdrun ${zdaemon_pkgdir}/zdrun.py
+  # This logfile should match the one in the zeo.conf file.
+  # It is used by zdctl's logtail command, zdrun/zdctl doesn't write it.
+  logfile $INSTANCE/log/zeo.log
+</runner>

Added: repoze.zope2/trunk/repoze/zope2/etc/zope-zeoclient.conf
==============================================================================
--- (empty file)
+++ repoze.zope2/trunk/repoze/zope2/etc/zope-zeoclient.conf	Sat Mar  1 05:03:47 2008
@@ -0,0 +1,63 @@
+###############################################################################
+# Welcome to Zope 2.
+###############################################################################
+#
+# This is the Zope configuration file.  The Zope configuration file
+# shows what the default configuration directives are, and show
+# examples for each directive.  To declare a directive, make sure that
+# you add it to a line that does not begin with '#'.  Note that comments 
+# are only allowed at the beginning of a line: you may not add comments
+# after directive text on the same line.
+
+%define INSTANCE ${sandbox}
+
+instancehome $INSTANCE
+products $INSTANCE/Products
+debug-mode on
+
+<eventlog>
+  level info
+  <logfile>
+    path STDERR
+    level info
+  </logfile>
+</eventlog>
+
+<logger access>
+  level WARN
+  <logfile>
+    path STDERR
+    format %(message)s
+  </logfile>
+</logger>
+
+<zodb_db temporary>
+    mount-point /temp_folder
+    <temporarystorage>
+      name sessions
+    </temporarystorage>
+    container-class Products.TemporaryFolder.TemporaryContainer
+</zodb_db>
+
+<zodb_db main>
+    mount-point /
+    cache-size 50000
+    <zeoclient>
+      server localhost:${zeo_port}
+      storage 1
+      cache-size 100MB
+      name zeostorage
+      var $INSTANCE/var
+    </zeoclient>
+</zodb_db>
+
+# Uncomment this to use a FileStorage as the main storage
+
+#<zodb_db main>
+#    mount-point /
+#    cache-size 50000
+#    <filestorage>
+#      path $INSTANCE/var/Data.fs
+#    </filestorage>
+#</zodb_db>
+

Added: repoze.zope2/trunk/repoze/zope2/etc/zope.conf
==============================================================================
--- (empty file)
+++ repoze.zope2/trunk/repoze/zope2/etc/zope.conf	Sat Mar  1 05:03:47 2008
@@ -0,0 +1,62 @@
+###############################################################################
+# Welcome to Zope 2.
+###############################################################################
+#
+# This is the Zope configuration file.  The Zope configuration file
+# shows what the default configuration directives are, and show
+# examples for each directive.  To declare a directive, make sure that
+# you add it to a line that does not begin with '#'.  Note that comments 
+# are only allowed at the beginning of a line: you may not add comments
+# after directive text on the same line.
+
+%define INSTANCE ${sandbox}
+
+instancehome $INSTANCE
+products $INSTANCE/Products
+debug-mode on
+
+<eventlog>
+  level info
+  <logfile>
+    path STDERR
+    level info
+  </logfile>
+</eventlog>
+
+<logger access>
+  level WARN
+  <logfile>
+    path STDERR
+    format %(message)s
+  </logfile>
+</logger>
+
+<zodb_db temporary>
+    mount-point /temp_folder
+    <temporarystorage>
+      name sessions
+    </temporarystorage>
+    container-class Products.TemporaryFolder.TemporaryContainer
+</zodb_db>
+
+<zodb_db main>
+    mount-point /
+    cache-size 50000
+    <filestorage>
+      path $INSTANCE/var/Data.fs
+    </filestorage>
+</zodb_db>
+
+# Uncomment this to use a ZEO server as the main storage.
+#
+# <zodb_db main>
+#     mount-point /
+#     cache-size 50000
+#     <zeoclient>
+#       server localhost:8100
+#       storage 1
+#       cache-size 100MB
+#       name zeostorage
+#       var $INSTANCE/var
+#     </zeoclient>
+# </zodb_db>

Added: repoze.zope2/trunk/repoze/zope2/etc/zope2.ini
==============================================================================
--- (empty file)
+++ repoze.zope2/trunk/repoze/zope2/etc/zope2.ini	Sat Mar  1 05:03:47 2008
@@ -0,0 +1,40 @@
+[DEFAULT]
+debug = True
+
+[app:zope2]
+paste.app_factory = repoze.obob.publisher:make_obob
+repoze.obob.get_root = repoze.zope2.z2bob:get_root
+repoze.obob.initializer = repoze.zope2.z2bob:initialize
+repoze.obob.helper_factory = repoze.zope2.z2bob:Zope2ObobHelper
+zope.conf = %(here)s/${zope_conf}
+
+[filter:errorlog]
+use = egg:repoze.errorlog#errorlog
+path = /__error_log__
+keep = 20
+ignore = paste.httpexceptions:HTTPUnauthorized
+       paste.httpexceptions:HTTPNotFound
+       paste.httpexceptions:HTTPFound
+
+[pipeline:main]
+pipeline = egg:Paste#cgitb
+           egg:Paste#httpexceptions
+#           egg:Paste#translogger
+           egg:repoze.retry#retry
+           egg:repoze.tm#tm
+           egg:repoze.vhm#vhm_xheaders 
+           errorlog
+           zope2
+
+# Note: replace egg:Paste#cgitb with egg:Paste#evalerror above to get
+# the browser to display eval'able traceback stacks (unsuitable for
+# production).
+
+# If you enable (uncomment) the translogger, it will show access log
+# info to the console.
+
+[server:main]
+use = egg:repoze.zope2#zserver
+host = 127.0.0.1
+port = ${zope_port}
+

Added: repoze.zope2/trunk/repoze/zope2/etc/zope2.wsgi
==============================================================================
--- (empty file)
+++ repoze.zope2/trunk/repoze/zope2/etc/zope2.wsgi	Sat Mar  1 05:03:47 2008
@@ -0,0 +1,13 @@
+"""
+
+Stub for running under mod_wsgi.  Intended to be used as a
+'WSGIScriptAlias' within the Apache configuration, e.g.::
+
+WSGIScriptAlias /site /path/to/sandbox/etc/zope2.wsgi
+
+""" 
+import os
+from paste.deploy import loadapp
+
+ini = '${sandbox}/etc/zope2.ini'
+application = loadapp('config:%s' % ini)

Modified: repoze.zope2/trunk/repoze/zope2/instance.py
==============================================================================
--- repoze.zope2/trunk/repoze/zope2/instance.py	(original)
+++ repoze.zope2/trunk/repoze/zope2/instance.py	Sat Mar  1 05:03:47 2008
@@ -14,9 +14,8 @@
         return kw[match.group(1)]
     return TOKEN_RE.sub(replace, repltext)
 
-def mkinstance(sandbox=None):
-    if sandbox is None:
-        sandbox = sys.prefix
+def mkinstance(conf):
+    sandbox = conf['sandbox']
         
     for dir in ('bin', 'etc', 'var', 'Products', 'import', 'log'):
         path = os.path.join(sandbox, dir)
@@ -27,27 +26,26 @@
         # this is (stupidly) required by the zdrun key in the <runner>
         # section of zeo.conf
         import zdaemon
-        zdaemon_pkgdir = zdaemon.__path__[0]
+        conf['zdaemon_pkgdir'] = zdaemon.__path__[0]
     except ImportError:
-        zdaemon_pkgdir = '{unknown}'
+        conf['zdaemon_pkgdir'] = '{unknown}'
         
     for source, target in (
-        ('sample-zope2.ini', 'zope2.ini'),
-        ('sample-site.zcml', 'site.zcml'),
-        ('sample-zope.conf', 'zope.conf'),
-        ('sample-apache2.conf', 'apache2.conf'),
-        ('sample-zeo.conf', 'zeo.conf'),
+        ('zope2.ini', 'zope2.ini'),
+        ('site.zcml', 'site.zcml'),
+        ('zope.conf', 'zope.conf'),
+        ('zope-zeoclient.conf', 'zope-zeoclient.conf'),
+        ('apache2.conf', 'apache2.conf'),
+        ('zeo.conf', 'zeo.conf'),
         ):
         template = open(os.path.join(here, 'etc', source), 'r').read()
-        result = rewrite(template, sandbox=sandbox,
-                         zdaemon_pkgdir=zdaemon_pkgdir,
-                         python=sys.executable)
+        result = rewrite(template, **conf)
         targetfile = os.path.join(sandbox, 'etc', target)
         if not os.path.exists(targetfile):
             open(targetfile, 'w').write(result)
 
-    template = open(os.path.join(here, 'etc', 'sample-zope2.wsgi'), 'r').read()
-    result = rewrite(template, sandbox=sandbox)
+    template = open(os.path.join(here, 'etc', 'zope2.wsgi'), 'r').read()
+    result = rewrite(template, **conf)
     targetfile = os.path.join(sandbox, 'bin', 'zope2.wsgi')
     if not os.path.exists(targetfile):
         open(targetfile, 'w').write(result)
@@ -56,15 +54,18 @@
 def main(argv=sys.argv):
     """ Console script target """
     parser = optparse.OptionParser(
-        usage='%prog [PATH]'
+        usage='%prog [OPTIONS]'
         )
+    parser.add_option('-d', '--directory', action='store', dest='sandbox',
+                      default='.', help='Create the instance in this directory')
+    parser.add_option('-p', '--http-port', action='store', dest='zope_port',
+                      default='8080', help='Zope HTTP port')
+    parser.add_option('-z', '--zeo-port', action='store', dest='zeo_port',
+                      default='', help='ZEO port (implies main storage in ZEO)')
     options, args = parser.parse_args(sys.argv)
-    if len(args) != 2:
-        parser.print_help(sys.stderr)
-        sys.exit(1)
-    path = os.path.realpath(os.path.expanduser(args[1]))
-    mkinstance(path)
-    
-    
-
-    
+    if options.zeo_port:
+        options.zope_conf = 'zope-zeoclient.conf'
+    else:
+        options.zope_conf = 'zope.conf'
+    options.python = sys.executable
+    mkinstance(options.__dict__)

Modified: repoze.zope2/trunk/setup.py
==============================================================================
--- repoze.zope2/trunk/setup.py	(original)
+++ repoze.zope2/trunk/setup.py	Sat Mar  1 05:03:47 2008
@@ -12,7 +12,7 @@
 #
 ##############################################################################
 
-__version__ = '0.3.0'
+__version__ = '0.3.1'
 
 from ez_setup import use_setuptools
 use_setuptools()


More information about the Repoze-checkins mailing list