Package: ore.wsgiapp
ore.wsgiapp-----------This packages allows one to bootstrap a zope3 environment as a wsgiapplication without a ZODB.Users of this package instead register the root object to be publishedas an IApplication utility, which is looked up and returned by thedefault publication. All object publishing/traversal continues on fromthis 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 applicationsDefine an Application=====================First we need to define an object which implements IApplication, which willbe the root of our published application, useful base classes for this purposeare in the ore.wsgiapp.app module.>>> from ore.wsgiapp import app>>> class MyApplication( app.Application ): passnow if we register this object as a utility it will be the root objectpublished 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.wsgiappzcml = test.zcmlApplication===========Its often useful to defer application setup till after the application has finished loading itsconfiguration, so that component architecture is fully configured. in order to allow for this, ore.wsgiappgenerates a IWSGIApplicationCreatedEvent with the application as an attribute. we can register a subscriberfor 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 applicationto automatically drop into a post mortem debugging session, in the python debugger, on an unhandledexception in the application. ore.wsgiapp supports pdb debug mode, simply by turning on the developermode configuration. The developer mode also enables other features in the zope stack, such as automaticreloading of page templates, etc.[app:main]use = egg:zope.publisherpublication = egg:zope.publisher#samplefoo = barDetailed example================There's a sample application class in ore.wsgiapp.tests.TestApp, along with a simple default viewore.wsgiapp.tests.AppView. We setup>>> test_zcml_contentsWe can create a WSGI application for this application by calling the ore.wsgiapp paste applicationfactory. 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 anenvironment 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_WHITESPACE200 OkHello World0.3.2 - May 1st, 2008- additional documentation and tests0.3.1 - January 10th, 2008- add app open event to hook setup after configuration loading0.3 - January 9th, 2008- First Public Release