summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-06-18 23:51:20 +0000
committerChris McDonough <chrism@agendaless.com>2009-06-18 23:51:20 +0000
commitfab8c5dc3555bad27214bcd3a6d8ace34fa32e86 (patch)
tree803f2eb8a6ef6bcfe0f360d17c8600ba00513741
parent306e12aab8645c4682dec33f3dd25001934409c3 (diff)
downloadpyramid-fab8c5dc3555bad27214bcd3a6d8ace34fa32e86.tar.gz
pyramid-fab8c5dc3555bad27214bcd3a6d8ace34fa32e86.tar.bz2
pyramid-fab8c5dc3555bad27214bcd3a6d8ace34fa32e86.zip
IForbiddenView utility registration -> forbidden directive
INotFoundView utility registry -> notfound directive
-rw-r--r--docs/narr/hooks.rst87
-rw-r--r--docs/tutorials/bfgwiki/authorization.rst8
-rw-r--r--docs/tutorials/bfgwiki/src/authorization/tutorial/configure.zcml4
3 files changed, 49 insertions, 50 deletions
diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst
index 53d6c8c77..dab8eaad7 100644
--- a/docs/narr/hooks.rst
+++ b/docs/narr/hooks.rst
@@ -4,44 +4,7 @@ Using ZCML Hooks
================
ZCML "hooks" can be used to influence the behavior of the
-:mod:`repoze.bfg` framework in various ways. This is an advanced
-topic; not many people will want or need to do any of these things.
-
-Changing the response factory
------------------------------
-
-You may change the class used as the "response factory" from within
-the :mod:`repoze.bfg` ``chameleon_zpt``, ``chameleon_genshi``,
-``chameleon_text`` (the ``render_template_to_response`` function used
-within each) and other various places where a Response object is
-constructed by :mod:`repoze.bfg`. The default "response factory" is
-the class ``webob.Response``. You may change it by placing the
-following ZCML in your ``configure.zcml`` file.
-
-.. code-block:: xml
- :linenos:
-
- <utility provides="repoze.bfg.interfaces.IResponseFactory"
- component="helloworld.factories.response_factory"/>
-
-Replace ``helloworld.factories.response_factory`` with the Python
-dotted name to the response factory you want to use. Here's some
-sample code that implements a minimal response factory:
-
-.. code-block:: python
-
- from webob import Response
-
- class MyResponse(Response):
- pass
-
- def response_factory():
- return MyResponse
-
-Unlike a request factory, a response factory does not need to return
-an object that implements any particular interface; it simply needs
-have a ``status`` attribute, a ``headerlist`` attribute, and and
-``app_iter`` attribute.
+:mod:`repoze.bfg` framework in various ways.
Changing the Not Found View
---------------------------
@@ -54,8 +17,8 @@ file.
.. code-block:: xml
:linenos:
- <utility provides="repoze.bfg.interfaces.INotFoundView"
- component="helloworld.views.notfound_view"/>
+ <notfound
+ view="helloworld.views.notfound_view"/>
Replace ``helloworld.views.notfound_view`` with the Python dotted name
to the notfound view you want to use. Here's some sample code that
@@ -87,10 +50,10 @@ following ZCML in your ``configure.zcml`` file.
.. code-block:: xml
:linenos:
- <utility provides="repoze.bfg.interfaces.IForbiddenView"
- component="helloworld.views.forbidden_view"/>
+ <forbidden
+ view="helloworld.views.forbidden_view"/>
-Replace ``helloworld.factories.forbidden_app_factory`` with the Python
+Replace ``helloworld.views.forbidden_view`` with the Python
dotted name to the forbidden view you want to use. Like any other
view, the forbidden view must accept two parameters: ``context`` and
``request`` . The ``context`` is the context found by the router when
@@ -102,7 +65,7 @@ code that implements a minimal forbidden view:
from repoze.bfg.chameleon_zpt import render_template_to_response
- def forbidden_response_factory(context, request):
+ def forbidden_view(context, request):
return render_template_to_response('templates/login_form.pt')
.. note:: When an forbidden view is invoked, it is passed
@@ -119,3 +82,39 @@ code that implements a minimal forbidden view:
an alterate forbidden view. For example, it would make sense to
return a response with a ``403 Forbidden`` status code.
+Changing the response factory
+-----------------------------
+
+You may change the class used as the "response factory" from within
+the :mod:`repoze.bfg` ``chameleon_zpt``, ``chameleon_genshi``,
+``chameleon_text`` (the ``render_template_to_response`` function used
+within each) and other various places where a Response object is
+constructed by :mod:`repoze.bfg`. The default "response factory" is
+the class ``webob.Response``. You may change it by placing the
+following ZCML in your ``configure.zcml`` file.
+
+.. code-block:: xml
+ :linenos:
+
+ <utility provides="repoze.bfg.interfaces.IResponseFactory"
+ component="helloworld.factories.response_factory"/>
+
+Replace ``helloworld.factories.response_factory`` with the Python
+dotted name to the response factory you want to use. Here's some
+sample code that implements a minimal response factory:
+
+.. code-block:: python
+
+ from webob import Response
+
+ class MyResponse(Response):
+ pass
+
+ def response_factory():
+ return MyResponse
+
+Unlike a request factory, a response factory does not need to return
+an object that implements any particular interface; it simply needs
+have a ``status`` attribute, a ``headerlist`` attribute, and and
+``app_iter`` attribute.
+
diff --git a/docs/tutorials/bfgwiki/authorization.rst b/docs/tutorials/bfgwiki/authorization.rst
index ea2366a72..bd4e80206 100644
--- a/docs/tutorials/bfgwiki/authorization.rst
+++ b/docs/tutorials/bfgwiki/authorization.rst
@@ -114,10 +114,10 @@ class="main_content">`` div:
Changing ``configure.zcml``
~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Change your application's ``configure.zcml`` to add a slightly
-inscrutable ``utility`` stanza. This configures our login view to
-show up when BFG detects that a view invocation can not be authorized.
-When you're done, your ``configure.zcml`` will look like so:
+Change your application's ``configure.zcml`` to add a ``forbidden``
+stanza. This configures our login view to show up when BFG detects
+that a view invocation can not be authorized. When you're done, your
+``configure.zcml`` will look like so:
.. literalinclude:: src/authorization/tutorial/configure.zcml
:linenos:
diff --git a/docs/tutorials/bfgwiki/src/authorization/tutorial/configure.zcml b/docs/tutorials/bfgwiki/src/authorization/tutorial/configure.zcml
index c8c0aa77e..d13d812a8 100644
--- a/docs/tutorials/bfgwiki/src/authorization/tutorial/configure.zcml
+++ b/docs/tutorials/bfgwiki/src/authorization/tutorial/configure.zcml
@@ -5,7 +5,7 @@
<scan package="."/>
- <utility provides="repoze.bfg.interfaces.IForbiddenView"
- component=".login.login"/>
+ <forbidden
+ view=".login.login"/>
</configure>