diff options
| author | Chris McDonough <chrism@agendaless.com> | 2010-09-05 22:39:20 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2010-09-05 22:39:20 +0000 |
| commit | d89aee7640b1e01a7dda4e603e87461074fbbdd7 (patch) | |
| tree | 16857b0c6fe0b0932903d13c10382732a7bf3b5f /docs/narr | |
| parent | 91255626afd43d558cbc4eb74865ccdf0b629417 (diff) | |
| download | pyramid-d89aee7640b1e01a7dda4e603e87461074fbbdd7.tar.gz pyramid-d89aee7640b1e01a7dda4e603e87461074fbbdd7.tar.bz2 pyramid-d89aee7640b1e01a7dda4e603e87461074fbbdd7.zip | |
- Each of the follow methods of the Configurator now allow the
below-named arguments to be passed as "dotted name strings"
(e.g. "foo.bar.baz") rather than as actual implementation objects
that must be imported:
setup_registry
root_factory, authentication_policy, authorization_policy,
debug_logger, locale_negotiator, request_factory,
renderer_globals_factory
add_subscriber
subscriber, iface
derive_view
view
add_view
view, for_, context, request_type, containment
add_route()
view, view_for, factory, for_, view_context
scan
package
add_renderer
factory
set_forbidden_view
view
set_notfound_view
view
set_request_factory
factory
set_renderer_globals_factory()
factory
set_locale_negotiator
negotiator
testing_add_subscriber
event_iface
Diffstat (limited to 'docs/narr')
| -rw-r--r-- | docs/narr/events.rst | 3 | ||||
| -rw-r--r-- | docs/narr/firstapp.rst | 17 | ||||
| -rw-r--r-- | docs/narr/hooks.rst | 9 | ||||
| -rw-r--r-- | docs/narr/i18n.rst | 8 | ||||
| -rw-r--r-- | docs/narr/security.rst | 5 | ||||
| -rw-r--r-- | docs/narr/traversal.rst | 5 | ||||
| -rw-r--r-- | docs/narr/urldispatch.rst | 25 | ||||
| -rw-r--r-- | docs/narr/views.rst | 13 |
8 files changed, 53 insertions, 32 deletions
diff --git a/docs/narr/events.rst b/docs/narr/events.rst index 7f78139bb..6b46cfd9c 100644 --- a/docs/narr/events.rst +++ b/docs/narr/events.rst @@ -58,7 +58,8 @@ need to use ZCML for the same purpose: The first argument to :meth:`repoze.bfg.configuration.Configurator.add_subscriber` is the - subscriber function; the second argument is the event type. + subscriber function (or a :term:`Python dotted name` which refers + to a subscriber callable); the second argument is the event type. .. topic:: Configuring an Event Listener Through ZCML diff --git a/docs/narr/firstapp.rst b/docs/narr/firstapp.rst index 01ad88704..deac69fda 100644 --- a/docs/narr/firstapp.rst +++ b/docs/narr/firstapp.rst @@ -235,14 +235,15 @@ arguments is known as a view configuration :term:`predicate`. The line ``config.add_view(hello_world)`` registers the ``hello_world`` function as a view callable. The ``add_view`` method -of a Configurator must be called with a view callable object as its -first argument, so the first argument passed is the ``hello_world`` -function. This line calls ``add_view`` with a *default* value for the -:term:`predicate` argument, named ``name``. The ``name`` predicate -defaults to a value equalling the empty string (``''``). This means -that we're instructing :mod:`repoze.bfg` to invoke the ``hello_world`` -view callable when the :term:`view name` is the empty string. We'll -learn in later chapters what a :term:`view name` is, and under which +of a Configurator must be called with a view callable object or a +:term:`dotted Python name` as its first argument, so the first +argument passed is the ``hello_world`` function. This line calls +``add_view`` with a *default* value for the :term:`predicate` +argument, named ``name``. The ``name`` predicate defaults to a value +equalling the empty string (``''``). This means that we're +instructing :mod:`repoze.bfg` to invoke the ``hello_world`` view +callable when the :term:`view name` is the empty string. We'll learn +in later chapters what a :term:`view name` is, and under which circumstances a request will have a view name that is the empty string; in this particular application, it means that the ``hello_world`` view callable will be invoked when the root URL ``/`` diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst index 70e3f3759..b774c2012 100644 --- a/docs/narr/hooks.rst +++ b/docs/narr/hooks.rst @@ -351,7 +351,8 @@ request object. The class (aka "factory") that :mod:`repoze.bfg` uses to create a request object instance can be changed by passing a ``request_factory`` argument to the constructor of the -:term:`configurator`. +:term:`configurator`. This argument can be either a callable or a +:term:`Python dotted name` representing a callable. .. code-block:: python :linenos: @@ -392,7 +393,7 @@ method: pass config = Configurator() - config.set_request_factory(MyRequestFactory) + config.set_request_factory(MyRequest) .. _adding_renderer_globals: @@ -411,7 +412,9 @@ renderer. A callback that :mod:`repoze.bfg` will call every time a renderer is invoked can be added by passing a ``renderer_globals_factory`` -argument to the constructor of the :term:`configurator`. +argument to the constructor of the :term:`configurator`. This +callback can either be a callable object or a :term:`Python dotted +name` representing such a callable. .. code-block:: python :linenos: diff --git a/docs/narr/i18n.rst b/docs/narr/i18n.rst index db1414cce..f456fe03c 100644 --- a/docs/narr/i18n.rst +++ b/docs/narr/i18n.rst @@ -1013,10 +1013,10 @@ configuration using either imperative configuration or ZCML. .. topic:: Using Imperative Configuration - Pass an object which can act as the negotiator as the - ``locale_negotiator`` argument of the - :class:`repoze.bfg.configuration.Configurator` instance during - application startup. + Pass an object which can act as the negotiator (or a :term:`Python + dotted name` referring to the object) as the ``locale_negotiator`` + argument of the :class:`repoze.bfg.configuration.Configurator` + instance during application startup. For example: diff --git a/docs/narr/security.rst b/docs/narr/security.rst index 13e6d632a..3b1de27ad 100644 --- a/docs/narr/security.rst +++ b/docs/narr/security.rst @@ -110,6 +110,11 @@ For example: config = Configurator(authentication_policy=authentication_policy, authorization_policy=authorization_policy) +.. note:: the ``authentication_policy`` and ``authorization_policy`` + arguments may also be passed to the Configurator as :ref:`dotted + Python name` values, each representing the dotted name path to a + suitable implementation global defined at Python module scope. + The above configuration enables a policy which compares the value of an "auth ticket" cookie passed in the request's environment which contains a reference to a single :term:`principal` against the diff --git a/docs/narr/traversal.rst b/docs/narr/traversal.rst index a99df7ec8..bcad6dd07 100644 --- a/docs/narr/traversal.rst +++ b/docs/narr/traversal.rst @@ -183,7 +183,10 @@ Using the ``root_factory`` argument to a :class:`repoze.bfg.configuration.Configurator` constructor tells your :mod:`repoze.bfg` application to call this root factory to generate a root object whenever a request enters the application. This root -factory is also known as the global root factory. +factory is also known as the global root factory. A root factory can +alternately be passed to the ``Configurator`` as a :term:`dotted +Python name` which refers to a root factory object defined in a +different module. A root factory is passed a :term:`request` object and it is expected to return an object which represents the root of the object graph. diff --git a/docs/narr/urldispatch.rst b/docs/narr/urldispatch.rst index 07e96763d..9779113e5 100644 --- a/docs/narr/urldispatch.rst +++ b/docs/narr/urldispatch.rst @@ -448,11 +448,11 @@ represent neither predicates nor view configuration information. application. ``factory`` - A reference to a Python object (often a function or a class) that - will generate a :mod:`repoze.bfg` :term:`context` object when this - route matches. For example, ``mypackage.models.MyFactoryClass``. If - this argument is not specified, the traversal root factory will be - used. + A Python object (often a function or a class) or a :term:`Python + dotted name` to such an object that will generate a + :mod:`repoze.bfg` :term:`context` object when this route + matches. For example, ``mypackage.models.MyFactoryClass``. If this + argument is not specified, the traversal root factory will be used. ``traverse`` If you would like to cause the :term:`context` to be something other @@ -573,15 +573,16 @@ represent neither predicates nor view configuration information. **View-Related Arguments** ``view`` - A reference to a Python object that will be used as a view callable - when this route matches. e.g. ``mypackage.views.my_view``. + A Python object or a :term:`dotted Python name` to such an object + that will be used as a view callable when this route + matches. e.g. ``mypackage.views.my_view``. ``view_context`` - A reference to a class or an :term:`interface` that the - :term:`context` of the view should match for the view named by the - route to be used. This argument is only useful if the ``view`` - attribute is used. If this attribute is not specified, the default - (``None``) will be used. + A class or an :term:`interface` (or a :term:`dotted Python name` to + such an object) that the :term:`context` of the view should match + for the view named by the route to be used. This argument is only + useful if the ``view`` attribute is used. If this attribute is not + specified, the default (``None``) will be used. If the ``view`` argument is not provided, this argument has no effect. diff --git a/docs/narr/views.rst b/docs/narr/views.rst index eebaa63de..4d60f8a9e 100644 --- a/docs/narr/views.rst +++ b/docs/narr/views.rst @@ -620,7 +620,8 @@ For example, to add a renderer which renders views which have a The first argument is the renderer name. The second argument is a reference to an implementation of a - :term:`renderer factory`. + :term:`renderer factory` or a :term:`dotted Python name` referring + to such an object. Adding a New Renderer +++++++++++++++++++++ @@ -1537,8 +1538,8 @@ Or replaces the need to add this imperative configuration stanza: .. ignore-next-block .. code-block:: python - config.add_view(name='my_view', request_method='POST', context=MyModel, - permission='read') + config.add_view('.views.my_view', name='my_view', request_method='POST', + context=MyModel, permission='read') All arguments to ``bfg_view`` may be omitted. For example: @@ -1748,6 +1749,12 @@ example: # repoze.bfg.configuration.Configurator class config.add_view(hello_world, name='hello.html') +The first argument, ``view``, is required. It must either be a Python +object which is the view itself or a :term:`dotted Python name` to +such an object. All other arguments are optional. See +:meth:`repoze.bfg.configuration.Configurator.add_view` for more +information. + .. index:: single: model interfaces |
