Chris McDonough
2009-12-17 bc857e7e6e71a4001f03c608a18bac7dab36ccff
refs
author Chris McDonough <chrism@agendaless.com>
Thursday, December 17, 2009 17:00 +0100
committer Chris McDonough <chrism@agendaless.com>
Thursday, December 17, 2009 17:00 +0100
commitbc857e7e6e71a4001f03c608a18bac7dab36ccff
tree a34b0b761a92791bb60b2fbfafabe79e4a675682 tree | zip | gz
parent 9d73300fcef0c0cd4af9c439a900d15fa4651914 view | diff
Features
--------

- The ``Configurator`` object now has two new methods: ``begin`` and
``end``. The ``begin`` method is meant to be called before any
"configuration" begins (e.g. before ``add_view``, et. al are
called). The ``end`` method is meant to be called after all
"configuration" is complete.

Previously, before there was imperative configuration at all (1.1
and prior), configuration begin and end was invariably implied by
the process of loading a ZCML file. When a ZCML load happened, the
threadlocal data structure containing the request and registry was
modified before the load, and torn down after the load, making sure
that all framework code that needed ``get_current_registry`` for the
duration of the ZCML load was satisfied.

Some API methods called during imperative configuration, (such as
``Configurator.add_view`` when a renderer is involved) end up for
historical reasons calling ``get_current_registry``. However, in
1.2a5 and below, the Configurator supplied no functionality that
allowed people to make sure that ``get_current_registry`` returned
the registry implied by the configurator being used. ``begin`` now
serves this purpose. Inversely, ``end`` pops the thread local
stack, undoing the actions of ``begin``.

We make this boundary explicit to reduce the potential for confusion
when the configurator is used in different circumstances (e.g. in
unit tests and app code vs. just in initial app setup).

Existing code written for 1.2a1-1.2a5 which does not call ``begin``
or ``end`` continues to work in the same manner it did before. It
is however suggested that this code be changed to call ``begin`` and
``end`` to reduce the potential for confusion in the future.

- All ``paster`` templates which generate an application skeleton now
make use of the new ``begin`` and ``end`` methods of the
Configurator they use in their respective copies of ``run.py`` and
``tests.py``.

Documentation
-------------

- All documentation that makes use of a ``Configurator`` object to do
application setup and test setup now makes use of the new ``begin``
and ``end`` methods of the configurator.

Bug Fixes
---------

- When a ``repoze.bfg.exceptions.NotFound`` or
``repoze.bfg.exceptions.Forbidden`` *class* (as opposed to instance)
was raised as an exception within a root factory (or route root
factory), the exception would not be caught properly by the
``repoze.bfg.`` Router and it would propagate to up the call stack,
as opposed to rendering the not found view or the forbidden view as
would have been expected.


43 files modified
675 ■■■■ changed files
CHANGES.txt 55 ●●●●● diff | view | raw | blame | history
docs/api/configuration.rst 4 ●●●● diff | view | raw | blame | history
docs/glossary.rst 12 ●●●●● diff | view | raw | blame | history
docs/narr/MyProject/myproject/run.py 2 ●●●●● diff | view | raw | blame | history
docs/narr/MyProject/myproject/tests.py 6 ●●●●● diff | view | raw | blame | history
docs/narr/configuration.rst 67 ●●●● diff | view | raw | blame | history
docs/narr/project.rst 2 ●●● diff | view | raw | blame | history
docs/narr/threadlocals.rst 14 ●●●●● diff | view | raw | blame | history
docs/narr/unittesting.rst 118 ●●●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki/src/authorization/tutorial/run.py 2 ●●●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki/src/authorization/tutorial/tests.py 2 ●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki/src/basiclayout/tutorial/run.py 2 ●●●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki/src/basiclayout/tutorial/tests.py 6 ●●●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki/src/models/tutorial/run.py 2 ●●●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki/src/models/tutorial/tests.py 6 ●●●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki/src/viewdecorators/tutorial/run.py 2 ●●●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki/src/viewdecorators/tutorial/tests.py 2 ●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki/src/views/tutorial/run.py 2 ●●●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki/src/views/tutorial/tests.py 2 ●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki2/src/authorization/tutorial/run.py 2 ●●●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki2/src/authorization/tutorial/tests.py 44 ●●●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki2/src/basiclayout/tutorial/run.py 2 ●●●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki2/src/basiclayout/tutorial/tests.py 6 ●●●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki2/src/models/tutorial/run.py 2 ●●●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki2/src/models/tutorial/tests.py 6 ●●●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki2/src/views/tutorial/run.py 2 ●●●●● diff | view | raw | blame | history
docs/tutorials/bfgwiki2/src/views/tutorial/tests.py 44 ●●●●● diff | view | raw | blame | history
docs/whatsnew-1.2.rst 15 ●●●●● diff | view | raw | blame | history
repoze/bfg/chameleon_text.py 2 ●●● diff | view | raw | blame | history
repoze/bfg/configuration.py 31 ●●●● diff | view | raw | blame | history
repoze/bfg/paster_templates/alchemy/+package+/run.py_tmpl 4 ●●● diff | view | raw | blame | history
repoze/bfg/paster_templates/routesalchemy/+package+/run.py_tmpl 4 ●●● diff | view | raw | blame | history
repoze/bfg/paster_templates/routesalchemy/+package+/tests.py_tmpl 6 ●●●●● diff | view | raw | blame | history
repoze/bfg/paster_templates/starter/+package+/run.py_tmpl 4 ●●● diff | view | raw | blame | history
repoze/bfg/paster_templates/starter/+package+/tests.py_tmpl 6 ●●●●● diff | view | raw | blame | history
repoze/bfg/paster_templates/zodb/+package+/run.py_tmpl 4 ●●● diff | view | raw | blame | history
repoze/bfg/paster_templates/zodb/+package+/tests.py_tmpl 6 ●●●●● diff | view | raw | blame | history
repoze/bfg/router.py 10 ●●●● diff | view | raw | blame | history
repoze/bfg/testing.py 52 ●●●● diff | view | raw | blame | history
repoze/bfg/tests/fixtureapp/views.py 3 ●●●●● diff | view | raw | blame | history
repoze/bfg/tests/test_configuration.py 54 ●●●● diff | view | raw | blame | history
repoze/bfg/tests/test_integration.py 2 ●●● diff | view | raw | blame | history
repoze/bfg/tests/test_router.py 56 ●●●●● diff | view | raw | blame | history