Skip to content

Commit

Permalink
move the IResponseFactory into the public api
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerickel committed Feb 7, 2015
1 parent c103548 commit da5f5f9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 19 deletions.
3 changes: 3 additions & 0 deletions docs/api/interfaces.rst
Expand Up @@ -56,6 +56,9 @@ Other Interfaces
.. autointerface:: IRenderer
:members:

.. autointerface:: IResponseFactory
:members:

.. autointerface:: IViewMapperFactory
:members:

Expand Down
3 changes: 2 additions & 1 deletion docs/glossary.rst
Expand Up @@ -18,7 +18,8 @@ Glossary

response factory
An object which, provided a :term:`request` as a single positional
argument, returns a Pyramid-compatible response.
argument, returns a Pyramid-compatible response. See
:class:`pyramid.interfaces.IResponseFactory`.

response
An object returned by a :term:`view callable` that represents response
Expand Down
8 changes: 4 additions & 4 deletions docs/narr/hooks.rst
Expand Up @@ -364,12 +364,12 @@ Whenever :app:`Pyramid` returns a response from a view it creates a
object.

The factory that :app:`Pyramid` uses to create a response object instance can be
changed by passing a ``response_factory`` argument to the constructor of the
:term:`configurator`. This argument can be either a callable or a
:term:`dotted Python name` representing a callable.
changed by passing a :class:`pyramid.interfaces.IResponseFactory` argument to
the constructor of the :term:`configurator`. This argument can be either a
callable or a :term:`dotted Python name` representing a callable.

The factory takes a single positional argument, which is a :term:`Request`
object. The argument may be the value ``None``.
object. The argument may be ``None``.

.. code-block:: python
:linenos:
Expand Down
5 changes: 2 additions & 3 deletions pyramid/config/factories.py
Expand Up @@ -102,9 +102,8 @@ def set_response_factory(self, factory):
""" The object passed as ``factory`` should be an object (or a
:term:`dotted Python name` which refers to an object) which
will be used by the :app:`Pyramid` as the default response
objects. This factory object must have the same
methods and attributes as the
:class:`pyramid.request.Response` class.
objects. The factory should conform to the
:class:`pyramid.interfaces.IResponseFactory` interface.
.. note::
Expand Down
11 changes: 5 additions & 6 deletions pyramid/interfaces.py
Expand Up @@ -582,12 +582,11 @@ def generate(path, request, **kw):
""" Generate a URL for the given path """

class IResponseFactory(Interface):
""" A utility which generates a response factory """
def __call__():
""" Return a response factory (e.g. a callable that returns an object
implementing IResponse, e.g. :class:`pyramid.response.Response`). It
should accept all the arguments that the Pyramid Response class
accepts."""
""" A utility which generates a response """
def __call__(request):
""" Return a response object implementing IResponse,
e.g. :class:`pyramid.response.Response`). It should handle the
case when ``request`` is ``None``."""

class IRequestFactory(Interface):
""" A utility which generates a request """
Expand Down
5 changes: 0 additions & 5 deletions pyramid/util.py
Expand Up @@ -15,10 +15,6 @@
CyclicDependencyError,
)

from pyramid.interfaces import (
IResponseFactory,
)

from pyramid.compat import (
iteritems_,
is_nonstr_iter,
Expand All @@ -29,7 +25,6 @@
)

from pyramid.interfaces import IActionInfo
from pyramid.response import Response
from pyramid.path import DottedNameResolver as _DottedNameResolver

class DottedNameResolver(_DottedNameResolver):
Expand Down

0 comments on commit da5f5f9

Please sign in to comment.