Commit 9ac28c17 authored by Hanno Schlichting's avatar Hanno Schlichting

Create a default PasteDeploy ini file as part of mkzopeinstance.

Currently this is not fully functional. repoze.retry causes errors
for failing to call start_response. Exceptions like NotFound aren't
turned into their HTML form by neither WebError nor paste#httpexceptions.
parent 72ae9a1b
...@@ -15,7 +15,6 @@ parts = ...@@ -15,7 +15,6 @@ parts =
allpy allpy
sphinx sphinx
checkversions checkversions
wsgi
requirements requirements
sources-dir = develop sources-dir = develop
auto-checkout = auto-checkout =
...@@ -140,19 +139,6 @@ recipe = zc.recipe.egg ...@@ -140,19 +139,6 @@ recipe = zc.recipe.egg
eggs = z3c.checkversions [buildout] eggs = z3c.checkversions [buildout]
[wsgi]
recipe = zc.recipe.egg
interpreter = wsgipy
eggs =
Zope2
repoze.who
repoze.tm2
repoze.retry
Paste
PasteDeploy
PasteScript
[requirements] [requirements]
recipe = plone.recipe.command recipe = plone.recipe.command
command = command =
......
Running Zope2 as a WSGI Application Running Zope2 as a WSGI Application
=================================== ===================================
This document assumes you have installed Zope into a ``virtualenv`` (see This document assumes you have installed Zope and created a Zope
:doc:`INSTALL-virtualenv`). instance home via `mkzopeinstance`.
The default configuration includes a WSGI configuration using
Update the Zope Application Configuration a PasteDeploy configuration file.
-----------------------------------------
The generated ``etc/zope.conf`` file assumes that Zope will be running
using the built-in ``ZServer``.
.. code-block:: sh
$ vim etc/zope.conf
Update the contents as follows.
.. code-block:: apacheconf
%define INSTANCE /path/to/virtualenv
instancehome $INSTANCE
.. note::
The ``%define instance /path/to/virtualenv`` element must
point to the environment: there is no "relative to this file" support
built in.
Set up logging for the application.
.. code-block:: apacheconf
<eventlog>
level info
<logfile>
path $INSTANCE/log/event.log
level info
</logfile>
</eventlog>
<logger access>
level WARN
<logfile>
path $INSTANCE/log/Z2.log
format %(message)s
</logfile>
</logger>
Configure the database (note that you could use ``ZEO`` or ``Relstorage``
rather than a bare ``FileStorage``):
.. code-block:: apacheconf
<zodb_db main>
# Main FileStorage database
<filestorage>
# See .../ZODB/component.xml for directives (sectiontype
# "filestorage").
path $INSTANCE/var/Data.fs
</filestorage>
mount-point /
</zodb_db>
<zodb_db temporary>
# Temporary storage database (for sessions)
<temporarystorage>
name temporary storage for sessioning
</temporarystorage>
mount-point /temp_folder
container-class Products.TemporaryFolder.TemporaryContainer
</zodb_db>
Because we will be running a separately-configured WSGI server, remove any
``<http-server>`` configuration from the file.
Create the WSGI Server Configuration
------------------------------------
.. code-block:: sh
$ vim etc/zope.wsgi
First, configure the "application" endpoint for Zope:
.. code-block:: ini
[app:zope]
use = egg:Zope2#main
zope_conf = %(here)s/zope.conf
Next, set up the WSGI middleware pipeline:
.. code-block:: ini
[pipeline:main]
pipeline =
egg:paste#evalerror
egg:repoze.retry#retry
egg:repoze.tm2#tm
zope
The middleware layers are "wrapped" around the application endpoint as follows:
- ``paste#evalerror`` is debugging middleware, which shows tracebacks for
errors raised from the application. It should **not** be configured for
production use.
- ``repoze.retry#retry`` is middleware which retries requests when retriable
exceptions are raised. By default, it retries 3 times, and only for
requests which raise ``ZODB.ConflictError``. See
http://repozeretry.rtfd.org/ for details on configuring it otherwise.
- ``repoze.tm2#tm`` is middleware which begins a new transaction for each
request, and then either aborts the transaction (if the request raises an
exception) or commits it (if not). See
http://repozetm2.rtfd.org/ for details on configuring it.
Finally, configure the WSGI server:
.. code-block:: ini
[server:main]
use = egg:paste#http
host = localhost
port = 8080
.. note::
Any server conforming to PEP 333/3333 should work, although the parameters
could change.
Set up the Admin User
---------------------
Before starting the WSGI server, run the ``addzope2user`` script to configure
the administrative user.
.. code-block:: sh
$ bin/addzope2user admin <yourpasswordhere>
No handlers could be found for logger "ZODB.FileStorage"
User admin created.
Start the WSGI Server Start the WSGI Server
......
...@@ -57,6 +57,8 @@ setup( ...@@ -57,6 +57,8 @@ setup(
'ExtensionClass', 'ExtensionClass',
'Missing', 'Missing',
'MultiMapping', 'MultiMapping',
'Paste',
'PasteDeploy',
'Persistence', 'Persistence',
'Products.OFSP >= 2.13.2', 'Products.OFSP >= 2.13.2',
'Products.SiteErrorLog', 'Products.SiteErrorLog',
...@@ -70,6 +72,8 @@ setup( ...@@ -70,6 +72,8 @@ setup(
'docutils', 'docutils',
'five.globalrequest', 'five.globalrequest',
'pytz', 'pytz',
'repoze.tm2',
'repoze.retry',
'setuptools', 'setuptools',
'tempstorage', 'tempstorage',
'transaction', 'transaction',
......
[app:zope]
use = egg:Zope2#main
zope_conf = %(here)s/wsgi.conf
[pipeline:main]
pipeline =
# egg:repoze.retry#retry
egg:repoze.tm2#tm
zope
[server:main]
use = egg:paste#http
host = 127.0.0.1
port = 8080
[loggers]
keys = root
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(asctime)s - %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %Y-%m-%d %H:%M:%S
...@@ -32,7 +32,6 @@ pytz = 2016.6.1 ...@@ -32,7 +32,6 @@ pytz = 2016.6.1
Record = 3.1 Record = 3.1
repoze.retry = 1.4 repoze.retry = 1.4
repoze.tm2 = 2.1 repoze.tm2 = 2.1
repoze.who = 2.3
RestrictedPython = 3.6.0 RestrictedPython = 3.6.0
six = 1.10.0 six = 1.10.0
tempstorage = 3.0 tempstorage = 3.0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment