Skip to content

Commit

Permalink
Create a default PasteDeploy ini file as part of mkzopeinstance.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hannosch committed Jul 21, 2016
1 parent 72ae9a1 commit 9ac28c1
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 159 deletions.
14 changes: 0 additions & 14 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ parts =
allpy
sphinx
checkversions
wsgi
requirements
sources-dir = develop
auto-checkout =
Expand Down Expand Up @@ -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 =
Expand Down
148 changes: 4 additions & 144 deletions docs/WSGI.rst
Original file line number Diff line number Diff line change
@@ -1,151 +1,11 @@
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
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def _read_file(filename):
'ExtensionClass',
'Missing',
'MultiMapping',
'Paste',
'PasteDeploy',
'Persistence',
'Products.OFSP >= 2.13.2',
'Products.SiteErrorLog',
Expand All @@ -70,6 +72,8 @@ def _read_file(filename):
'docutils',
'five.globalrequest',
'pytz',
'repoze.tm2',
'repoze.retry',
'setuptools',
'tempstorage',
'transaction',
Expand Down
37 changes: 37 additions & 0 deletions src/Zope2/utilities/skel/etc/zope.ini.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[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
1 change: 0 additions & 1 deletion versions-prod.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9ac28c1

Please sign in to comment.