Skip to main content
ore.wsgiapp
-----------

This packages allows one to bootstrap a zope3 environment as a wsgi
application without a ZODB.

Users of this package instead register the root object to be published
as an IApplication utility, which is looked up and returned by the
default publication. All object publishing/traversal continues on from
this user defined root object.

In addition, this package supports standard zope3 zcml loading, and debug features.

Usage
-----

A brief tutorial in using ore.wsgiapp to construct applications


Define an Application
=====================


First we need to define an object which implements IApplication, which will
be the root of our published application, useful base classes for this purpose
are in the ore.wsgiapp.app module.

>>> from ore.wsgiapp import app
>>> class MyApplication( app.Application ): pass

now if we register this object as a utility it will be the root object
published by zope.

>>> provideUtility( MyApplication )

you will still need to provide views, subobjects, etc.

Paste Configuration
===================

To use with Paste, you include a configuration section like::

where:

[app:zope]
use = egg:ore.wsgiapp
zcml = test.zcml

Application
===========

Its often useful to defer application setup till after the application has finished loading its
configuration, so that component architecture is fully configured. in order to allow for this, ore.wsgiapp
generates a IWSGIApplicationCreatedEvent with the application as an attribute. we can register a subscriber
for this in zcml, and it will be invoked after configuration is loaded.

As an example we'll use an event subscriber to

>>> from zope.app.component import site
>>> from zope.app.container.sample import SampleContainer
>>>
>>> def appSetUp( app, eventevent ):
... """Initialize an application"""
...
... # setup a local site manager
... sm = site.LocalSiteManager( self.context )
... self.context.setSiteManager( sm )
...
... # add a folder
... app['news'] = SampleContainer()


PDB Debug Mode
==============

A useful facility for application development supported by ore.wsgiapp is to allow the application
to automatically drop into a post mortem debugging session, in the python debugger, on an unhandled
exception in the application. ore.wsgiapp supports pdb debug mode, simply by turning on the developer
mode configuration. The developer mode also enables other features in the zope stack, such as automatic
reloading of page templates, etc.

[app:main]
use = egg:zope.publisher
publication = egg:zope.publisher#sample
foo = bar

Detailed example
================

There's a sample application class in ore.wsgiapp.tests.TestApp, along with a simple default view
ore.wsgiapp.tests.AppView. We setup

>>> test_zcml_contents

We can create a WSGI application for this application by calling the ore.wsgiapp paste application
factory. This app accepts zcml keyword arg to point to a initial application configuration, and a devmode boolean switch. We'll get the factory by looking it up with package resources:

>>> import pkg_resources
>>> app_factory = pkg_resources.load_entry_point(
... 'ore.wsgiapp', 'paste.app_factory', 'main')

>>> app = app_factory(dict(global_option=42),
... zcml=test_zcml_path)


We can perform a test web request by calling the app factory with an
environment dictionary and a start-response function:

>>> def start_response(status, headers):
... print status
>>> import cStringIO
>>> env = {'CONTENT_TYPE': 'text/plain', 'PATH_INFO': '/',
... 'REQUEST_METHOD': 'GET', 'wsgi.input': cStringIO.StringIO('')}

>>> for data in app(env, start_response):
... print data,
... # doctest: +NORMALIZE_WHITESPACE
200 Ok
Hello World


0.3.2 - May 1st, 2008

- additional documentation and tests

0.3.1 - January 10th, 2008

- add app open event to hook setup after configuration loading

0.3 - January 9th, 2008

- First Public Release

Metadata

Release files for ore.wsgiapp 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ore.wsgiapp 0.3.2
File Size Uploaded
ore.wsgiapp-0.3.2.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ore.wsgiapp 0.3.2
File Interpreter ABI Platform
ore.wsgiapp-0.3.2-py2.5.egg Legacy Egg format - - Details

Total release size: 25.0 kB

Release files / ore.wsgiapp-0.3.2.tar.gz

Download URL ore.wsgiapp-0.3.2.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
acf635062f681e024aed6f27926b9e03a3017744e02a4fba43dc0af3edba8478
BLAKE2b-256 checksum
How to use checksums
99bd92882294ae1efccd70825b8f36ca41b55e6fe1b9004537f07d6edb362d9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / ore.wsgiapp-0.3.2-py2.5.egg

Download URL ore.wsgiapp-0.3.2-py2.5.egg
Size 17.7 kB
Tags Egg
SHA-256 checksum
How to use checksums
2b4d43896770fdf15a2156c8c01f401ce7ee976db6407c7ce18f3d1934cb3ea3
BLAKE2b-256 checksum
How to use checksums
bdbc48ea26daeec4eaadebe9673e9619e4eaacfd15298459cc6ffe4dac4341c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page