summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-11-23 08:30:38 +0000
committerChris McDonough <chrism@agendaless.com>2009-11-23 08:30:38 +0000
commit44b2ca3219cf495ae0d3a66b81befdf368ef916d (patch)
tree8ca301dbb764f7c6de494a75a93915d8130511bf
parentbd39b16939147d667e9c483e341c0e0a14284eec (diff)
downloadpyramid-44b2ca3219cf495ae0d3a66b81befdf368ef916d.tar.gz
pyramid-44b2ca3219cf495ae0d3a66b81befdf368ef916d.tar.bz2
pyramid-44b2ca3219cf495ae0d3a66b81befdf368ef916d.zip
- The ``repoze.bfg.router.make_app`` function is now nominally
deprecated. Its import and usage does not throw a warning, nor will it probably ever disappear. However, using a ``repoze.bfg.configuration.Configurator`` class is now the preferred way to generate a WSGI application. - The ``run.py`` module in various ``repoze.bfg`` ``paster`` templates now use a ``repoze.bfg.configuration.Configurator`` class instead of the (now-legacy) ``repoze.bfg.router.make_app`` function to produce a WSGI application.
-rw-r--r--CHANGES.txt14
-rw-r--r--docs/narr/MyProject/myproject/configure.zcml1
-rw-r--r--docs/narr/MyProject/myproject/run.py12
-rw-r--r--docs/narr/configuration.rst3
-rw-r--r--docs/narr/project.rst11
-rw-r--r--repoze/bfg/paster_templates/alchemy/+package+/run.py_tmpl9
-rw-r--r--repoze/bfg/paster_templates/routesalchemy/+package+/run.py_tmpl7
-rw-r--r--repoze/bfg/paster_templates/starter/+package+/run.py_tmpl12
-rw-r--r--repoze/bfg/paster_templates/zodb/+package+/run.py_tmpl9
9 files changed, 50 insertions, 28 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index cabb15d6c..951e97efd 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -12,6 +12,11 @@ Features
function did not create a request object; it instead assigned
``None`` to the threadlocal request value.
+- The ``run.py`` module in various ``repoze.bfg`` ``paster`` templates
+ now use a ``repoze.bfg.configuration.Configurator`` class instead of
+ the (now-legacy) ``repoze.bfg.router.make_app`` function to produce
+ a WSGI application.
+
Bug Fixes
----------
@@ -186,6 +191,15 @@ Backwards Incompatibilites
add an attribute to your unit test request object named
``registry`` with the result.
+Deprecations
+------------
+
+- The ``repoze.bfg.router.make_app`` function is now nominally
+ deprecated. Its import and usage does not throw a warning, nor will
+ it probably ever disappear. However, using a
+ ``repoze.bfg.configuration.Configurator`` class is now the preferred
+ way to generate a WSGI application.
+
1.1.1 (2009-11-21)
==================
diff --git a/docs/narr/MyProject/myproject/configure.zcml b/docs/narr/MyProject/myproject/configure.zcml
index 038f04da4..fe9633fe1 100644
--- a/docs/narr/MyProject/myproject/configure.zcml
+++ b/docs/narr/MyProject/myproject/configure.zcml
@@ -1,6 +1,5 @@
<configure xmlns="http://namespaces.repoze.org/bfg">
- <!-- this must be included for the view declarations to work -->
<include package="repoze.bfg.includes" />
<view
diff --git a/docs/narr/MyProject/myproject/run.py b/docs/narr/MyProject/myproject/run.py
index 65cd6dfe6..a9d9973bd 100644
--- a/docs/narr/MyProject/myproject/run.py
+++ b/docs/narr/MyProject/myproject/run.py
@@ -1,11 +1,13 @@
-from repoze.bfg.router import make_app
+from repoze.bfg.configuration import Configurator
+from myproject.models import get_root
def app(global_config, **settings):
""" This function returns a repoze.bfg.router.Router object. It
is usually called by the PasteDeploy framework during ``paster
serve``"""
- # paster app config callback
- from myproject.models import get_root
- import myproject
- return make_app(get_root, myproject, settings=settings)
+ zcml_file = settings.get('configure_zcml', 'configure.zcml')
+ config = Configurator(root_factory=get_root, settings=settings,
+ zcml_file=zcml_file)
+ return config.make_wsgi_app()
+
diff --git a/docs/narr/configuration.rst b/docs/narr/configuration.rst
index c4f502031..6be8daa73 100644
--- a/docs/narr/configuration.rst
+++ b/docs/narr/configuration.rst
@@ -347,8 +347,7 @@ In a file named ``helloworld.py``:
return Response('Hello world!')
if __name__ == '__main__':
- config = Configurator()
- config.load_zcml()
+ config = Configurator(zcml_file='configure.zcml')
app = config.make_wsgi_app()
simple_server.make_server('', 8080, app).serve_forever()
diff --git a/docs/narr/project.rst b/docs/narr/project.rst
index 776f6f9a8..80fe6beac 100644
--- a/docs/narr/project.rst
+++ b/docs/narr/project.rst
@@ -692,11 +692,14 @@ without the PasteDeploy configuration file:
.. literalinclude:: MyProject/myproject/run.py
:linenos:
-#. Line 1 imports the ``make_app`` functions from
- :mod:`repoze.bfg.router` that we use later.
+#. Line 1 imports the ``Configurator`` class from
+ :mod:`repoze.bfg.configuration` that we use later.
-#. Lines 3-10 define a function that returns a :mod:`repoze.bfg` Router
- application from :ref:`router_module` . This is meant to be called
+#. Line 2 imports the ``get_root`` function from
+ :mod:`myproject.models` that we use later.
+
+#. Lines 4-11 define a function that returns a :mod:`repoze.bfg`
+ WSGI application. This function is meant to be called
by the :term:`PasteDeploy` framework as a result of running
``paster serve``.
diff --git a/repoze/bfg/paster_templates/alchemy/+package+/run.py_tmpl b/repoze/bfg/paster_templates/alchemy/+package+/run.py_tmpl
index d0ded775f..5eeaf1cba 100644
--- a/repoze/bfg/paster_templates/alchemy/+package+/run.py_tmpl
+++ b/repoze/bfg/paster_templates/alchemy/+package+/run.py_tmpl
@@ -1,6 +1,5 @@
-from repoze.bfg.router import make_app
+from repoze.bfg.configuration import Configurator
-import {{package}}
from {{package}}.models import appmaker
from {{package}}.models import DBSession
@@ -26,4 +25,8 @@ def app(global_config, **settings):
if db_echo is None:
db_echo = True
get_root = appmaker(db_string, db_echo)
- return make_app(get_root, {{package}}, settings=settings)
+ zcml_file = settings.get('configure_zcml', 'configure.zcml')
+ config = Configurator(settings=settings, root_factory=get_root,
+ zcml_file=zcml_file)
+ return config.make_wsgi_app()
+
diff --git a/repoze/bfg/paster_templates/routesalchemy/+package+/run.py_tmpl b/repoze/bfg/paster_templates/routesalchemy/+package+/run.py_tmpl
index d5a0f9326..e0e705224 100644
--- a/repoze/bfg/paster_templates/routesalchemy/+package+/run.py_tmpl
+++ b/repoze/bfg/paster_templates/routesalchemy/+package+/run.py_tmpl
@@ -1,6 +1,5 @@
-from repoze.bfg.router import make_app
+from repoze.bfg.configuration import Configurator
-import {{package}}
from {{package}}.models import DBSession
from {{package}}.models import initialize_sql
@@ -23,5 +22,7 @@ def app(global_config, **settings):
if db_string is None:
raise ValueError("No 'db_string' value in application configuration.")
initialize_sql(db_string)
- return make_app(None, {{package}}, settings=settings)
+ zcml_file = settings.get('configure_zcml', 'configure.zcml')
+ config = Configurator(settings=settings, zcml_file=zcml_file)
+ return config.make_wsgi_app()
diff --git a/repoze/bfg/paster_templates/starter/+package+/run.py_tmpl b/repoze/bfg/paster_templates/starter/+package+/run.py_tmpl
index 0cfac921f..b7cd4b2c3 100644
--- a/repoze/bfg/paster_templates/starter/+package+/run.py_tmpl
+++ b/repoze/bfg/paster_templates/starter/+package+/run.py_tmpl
@@ -1,11 +1,11 @@
-from repoze.bfg.router import make_app
+from repoze.bfg.configuration import Configurator
+from {{package}}.models import get_root
def app(global_config, **settings):
""" This function returns a repoze.bfg.router.Router object. It
is usually called by the PasteDeploy framework during ``paster
serve``"""
- # paster app config callback
- from {{package}}.models import get_root
- import {{package}}
- return make_app(get_root, {{package}}, settings=settings)
-
+ zcml_file = settings.get('configure_zcml', 'configure.zcml')
+ config = Configurator(root_factory=get_root,
+ settings=settings, zcml_file=zcml_file)
+ return config.make_wsgi_app()
diff --git a/repoze/bfg/paster_templates/zodb/+package+/run.py_tmpl b/repoze/bfg/paster_templates/zodb/+package+/run.py_tmpl
index e61816f9a..4fc20798d 100644
--- a/repoze/bfg/paster_templates/zodb/+package+/run.py_tmpl
+++ b/repoze/bfg/paster_templates/zodb/+package+/run.py_tmpl
@@ -1,4 +1,4 @@
-from repoze.bfg.router import make_app
+from repoze.bfg.configuration import Configurator
from repoze.zodbconn.finder import PersistentApplicationFinder
def app(global_config, **settings):
@@ -6,8 +6,6 @@ def app(global_config, **settings):
It is usually called by the PasteDeploy framework during ``paster serve``.
"""
- # paster app config callback
- import {{package}}
from {{package}}.models import appmaker
zodb_uri = settings.get('zodb_uri')
if zodb_uri is None:
@@ -16,4 +14,7 @@ def app(global_config, **settings):
finder = PersistentApplicationFinder(zodb_uri, appmaker)
def get_root(request):
return finder(request.environ)
- return make_app(get_root, {{package}}, settings=settings)
+ zcml_file = settings.get('configure_zcml', 'configure.zcml')
+ config = Configurator(root_factory=get_root,
+ settings=settings, zcml_file=zcml_file)
+ return config.make_wsgi_app()