From fab8c5dc3555bad27214bcd3a6d8ace34fa32e86 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 18 Jun 2009 23:51:20 +0000 Subject: IForbiddenView utility registration -> forbidden directive INotFoundView utility registry -> notfound directive --- docs/narr/hooks.rst | 87 +++++++++++----------- docs/tutorials/bfgwiki/authorization.rst | 8 +- .../src/authorization/tutorial/configure.zcml | 4 +- 3 files changed, 49 insertions(+), 50 deletions(-) (limited to 'docs') 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: - - - -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: - + 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: - + -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: + + + +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 @@ - + -- cgit v1.2.3