Skip to content

Commit

Permalink
- Added support for Python 3.3.
Browse files Browse the repository at this point in the history
- Dropped support for Python 2.4 and 2.5.

- Removed support for employing WSGI middlewares inside a Zope 3
  application. Only the script-based server startup is now supported.
  • Loading branch information
strichter committed Feb 27, 2013
1 parent 1f35721 commit fa66cf7
Show file tree
Hide file tree
Showing 19 changed files with 173 additions and 347 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
*.pyc
*.so
*.dll
*.xml
__pycache__
src/*.egg-info
src/zope/paste/test_app/Data*

.coverage
.installed.cfg
.tox
bin
Expand Down
17 changes: 10 additions & 7 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
Change History
--------------

0.5 (unreleased)
~~~~~~~~~~~~~~~~
1.0.0a1 (unreleased)
~~~~~~~~~~~~~~~~~~~~

- Added support for Python 3.3.

- Dropped support for Python 2.4 and 2.5.

- Removed support for employing WSGI middlewares inside a Zope 3
application. Only the script-based server startup is now supported.

- Added a new console script to run a paste-configured WSGI server and
application.

- Conform to standard ZF project layout.

- Make ``zope.app.twisted`` and ``zope.app.server`` optional dependencies by
putting them into extras. They are not needed at all, if we use PasteScript
to start up the application server.

- Added license and copyright file. Also fixed copyright statement in file
headers.

- Added manifest.
- Added ``MANIFEST.in`` and ``tox.ini``.


0.4 (2012-08-21)
Expand Down
109 changes: 5 additions & 104 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,118 +1,19 @@
zope.paste - Zope 3 and PasteDeploy
===================================

zope.paste allows you to

* employ WSGI middlewares inside a Zope 3 application

* deploy the Zope 3 application server on any WSGI-capable webserver

using PasteDeploy_. These are two completely different modi operandi
which only have in common that they are facilitate PasteDeploy_. Each
is explained in detail below.
zope.paste allows you to deploy the Zope 3 application server on any
WSGI-capable webserver using PasteDeploy_.

.. _PasteDeploy: http://pythonpaste.org/deploy/


WSGI middlewares inside Zope 3
------------------------------

zope.paste allows you to stack WSGI middlewares on top of Zope 3's
publisher application without changing the way you configure Zope
(``zope.conf``) or run it (``runzope``, ``zopectl``).

Configuration is very simple. Assuming that you've already created a
Zope 3 instance using the ``mkzopeinstance`` script, there are three
steps that need to be performed:

Installing and configuring zope.paste
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

zope.paste can be installed as an egg anywhere onto your
``PYTHONPATH`` or simply dropped into your
``<INSTANCE_HOME>/lib/python`` directory. Then you need to enable
zope.paste's ZCML configuration by creating the file
``<INSTANCE_HOME>/etc/package-includes/zope.paste-configure.zcml``
with the following contents::

<include package="zope.paste" />

Configuring the server
~~~~~~~~~~~~~~~~~~~~~~

We create a ``<server>`` directive in
``<INSTANCE_HOME>/etc/zope.conf`` to use zope.paste's server
definition, ``Paste.Main``. That way the WSGI middlewares will be
invoked when responses are served through this server::

<server>
type Paste.Main
address 8081
</server>

Configuring the WSGI stack
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now we configure a WSGI application using PasteDeploy_ syntax in
``<INSTANCE_HOME>/etc/paste.ini``. Here's an example of how to
configure the `Paste.Main` application to use the Zope 3 publisher as
a WSGI application, therefore doing the exact same thing that the
regular ``HTTP`` server definition would do::

[app:Paste.Main]
paste.app_factory = zope.paste.application:zope_publisher_app_factory

That's not really interesting, though. PasteDeploy_ allows you to
chain various WSGI entities together, which is where it gets
interesting. There seems to be a distinction between 'apps' and
'filters' (also referred to as 'middleware'). An example that might
be of interest is applying a `XSLT` transformation to the output of
the Zope 3 WSGI application.

Happily enough, someone seems to have already created a WSGI filter
for applying a `XSLT` stylesheet. You can find it at
http://www.decafbad.com/2005/07/xmlwiki/lib/xmlwiki/xslfilter.py

If you wanted to apply this WSGI filter to Zope 3, you would need
three things:

1. Put the ``xslfilter.py`` file somewhere in ``PYTHONPATH``.
``<INSTANCE>/lib/python`` is a good place.

2. Add this snippet to the bottom of ``xslfilter.py``::

def filter_factory(global_conf, **local_conf):
def filter(app):
return XSLFilter(app)
return filter

3. Change ``paste.ini`` file as follows::

[pipeline:Paste.Main]
pipeline = xslt main

[app:main]
paste.app_factory = zope.paste.application:zope_publisher_app_factory

[filter:xslt]
paste.filter_factory = xslfilter:filter_factory

What this does is to define a *pipeline*. Learn more about this on
the PasteDeploy_ website. Refer to the source of ``xslfilter.py``
for information about how to pass a stylesheet to the filter.


Deploying Zope 3 on an WSGI-capable webserver
---------------------------------------------

zope.paste allows you to run Zope 3 on any WSGI-capable webserver
software using PasteDeploy_. For this you will no longer need a Zope
3 instance (though you can still have one), you won't configure Zope 3
through ``zope.conf`` and won't start it using ``runzope`` or
``zopectl``.

Configuring the application
~~~~~~~~~~~~~~~~~~~~~~~~~~~
---------------------------

zope.paste provides a PasteDeploy_-compatible factory for Zope 3's
WSGI publisher application and registers it in an entry point. We can
Expand All @@ -130,7 +31,7 @@ known from a Zope 3 instance. You can, for example, put ``paste.ini``
into an existing Zope 3 instance, next to ``site.zcml``.

Configuring the ZODB database
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----------------------------

Instead of referring to a ZODB FileStorage using the ``file_storage``
setting, you can also configure multiple or other ZODB database
Expand All @@ -151,7 +52,7 @@ Refer to this file from ``paste.ini`` this way (and delete the
db_definition = db.conf

Configuring the server
~~~~~~~~~~~~~~~~~~~~~~
----------------------

In order to be able to use our Zope application, we only need to add a
server definition. We can use the one that comes with Paste or
Expand Down
Binary file added ZODB-4.0.0dev.tar.gz
Binary file not shown.
33 changes: 27 additions & 6 deletions buildout.cfg
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
[buildout]
parts = python test server
develop = .
find-links =
${buildout:directory}/ZODB-4.0.0dev.tar.gz
${buildout:directory}/zope.app.appsetup-4.0.0a1.dev.tar.gz
${buildout:directory}/zope.app.publication-4.0.0a1.dev.tar.gz
${buildout:directory}/zope.app.wsgi-4.0.0a1.dev.tar.gz
versions = versions

[python]
recipe = zc.recipe.egg
eggs =
zope.paste [test-app]
eggs = zope.paste [test-app]
interpreter = py

[test]
recipe = zc.recipe.testrunner
eggs =
zope.paste
eggs = zope.paste [test-app]

[server]
recipe = zc.recipe.egg
eggs =
zope.paste [test-app]
eggs = zope.paste [test-app]
scripts = serve=serve-test-app
arguments = sys.argv[1:] or \
['${buildout:directory}/src/zope/paste/test_app/app.ini']

[versions]
ZODB = 4.0.0dev
zope.app.appsetup = 4.0.0a1.dev
zope.app.publication = 4.0.0a1.dev
zope.app.wsgi = 4.0.0a1.dev
zope.container = 4.0.0a2
zope.i18n = 4.0.0a4
zope.index = 4.0.0
zope.intid = 4.0.0a1
zope.keyreference = 4.0.0a2
zope.principalregistry = 4.0.0a1
zope.publisher = 4.0.0a2
zope.security = 4.0.0a3
zope.session = 4.0.0a1
zope.site = 4.0.0a1
zope.tal = 4.0.0a1
zope.traversing = 4.0.0a2

37 changes: 19 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,22 @@
def read_file(filename):
return open(os.path.join(os.path.dirname(__file__), filename)).read()

TEST_APP_REQUIRES = [
'waitress',
'zope.app.publication',
'zope.authentication',
'zope.browserpage',
'zope.component',
'zope.error',
'zope.principalregistry',
'zope.publisher',
'zope.security',
'zope.site',
'zope.traversing',
]
setup(
name="zope.paste",
version='0.5.dev0',
version='1.0.0a1.dev0',
author="Sidnei da Silva and the Zope Community",
author_email="zope-dev@zope.org",
description="Zope 3 and PasteDeploy",
Expand All @@ -42,8 +55,8 @@ def read_file(filename):
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
#'Programming Language :: Python :: 3',
#'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: Implementation :: CPython',
'Natural Language :: English',
'Operating System :: OS Independent',
Expand All @@ -56,28 +69,16 @@ def read_file(filename):
include_package_data=True,
zip_safe=False,
extras_require={
'test-app': [
'waitress',
'zope.app.publication',
'zope.authentication',
'zope.browserpage',
'zope.component',
'zope.error',
'zope.principalregistry',
'zope.publisher',
'zope.security',
'zope.site',
'zope.traversing',
],
'twisted': ['zope.app.twisted'],
'zserver': ['zope.app.server'],
'test-app': TEST_APP_REQUIRES,
},
install_requires=[
'setuptools',
'PasteDeploy',
'zope.interface',
'zope.app.appsetup',
'zope.app.wsgi'],
tests_require=TEST_APP_REQUIRES,
test_suite='zope.paste.tests.test_suite',
entry_points = """
[paste.app_factory]
main = zope.paste.factory:zope_app_factory
Expand Down
64 changes: 0 additions & 64 deletions src/zope/paste/_server.py

This file was deleted.

Loading

0 comments on commit fa66cf7

Please sign in to comment.