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 =
allpy
sphinx
checkversions
wsgi
requirements
sources-dir = develop
auto-checkout =
......@@ -140,19 +139,6 @@ recipe = zc.recipe.egg
eggs = z3c.checkversions [buildout]
[wsgi]
recipe = zc.recipe.egg
interpreter = wsgipy
eggs =
Zope2
repoze.who
repoze.tm2
repoze.retry
Paste
PasteDeploy
PasteScript
[requirements]
recipe = plone.recipe.command
command =
......
Running Zope2 as a WSGI Application
===================================
This document assumes you have installed Zope into a ``virtualenv`` (see
:doc:`INSTALL-virtualenv`).
This document assumes you have installed Zope and created a Zope
instance home via `mkzopeinstance`.
Update the Zope Application Configuration
-----------------------------------------
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.
The default configuration includes a WSGI configuration using
a PasteDeploy configuration file.
Start the WSGI Server
......
......@@ -57,6 +57,8 @@ setup(
'ExtensionClass',
'Missing',
'MultiMapping',
'Paste',
'PasteDeploy',
'Persistence',
'Products.OFSP >= 2.13.2',
'Products.SiteErrorLog',
......@@ -70,6 +72,8 @@ setup(
'docutils',
'five.globalrequest',
'pytz',
'repoze.tm2',
'repoze.retry',
'setuptools',
'tempstorage',
'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
Record = 3.1
repoze.retry = 1.4
repoze.tm2 = 2.1
repoze.who = 2.3
RestrictedPython = 3.6.0
six = 1.10.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