From fbbb20c7953370c86f999e865b1a9d682690eb70 Mon Sep 17 00:00:00 2001 From: Brian Sutherland Date: Sat, 16 Jun 2012 12:57:46 +0200 Subject: A context manager for test setup --- docs/api/testing.rst | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs/api') diff --git a/docs/api/testing.rst b/docs/api/testing.rst index f388dc263..1366a1795 100644 --- a/docs/api/testing.rst +++ b/docs/api/testing.rst @@ -9,6 +9,8 @@ .. autofunction:: tearDown + .. autofunction:: testConfig(registry=None, request=None, hook_zca=True, autocommit=True, settings=None) + .. autofunction:: cleanUp .. autoclass:: DummyResource -- cgit v1.2.3 From 07cb8f0e112642a6a40127232ddc06125a73750e Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sat, 15 Sep 2012 18:58:45 -0400 Subject: add pyramid.decorator.reify as an API. Closes #682 --- docs/api/decorator.rst | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 docs/api/decorator.rst (limited to 'docs/api') diff --git a/docs/api/decorator.rst b/docs/api/decorator.rst new file mode 100644 index 000000000..35d9131df --- /dev/null +++ b/docs/api/decorator.rst @@ -0,0 +1,9 @@ +.. _decorator_module: + +:mod:`pyramid.decorator` +-------------------------- + +.. automodule:: pyramid.decorator + +.. autofunction:: reify + -- cgit v1.2.3 From 277b2af26871a4d84730b6d3e38fbaa2f4102823 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 16 Sep 2012 02:33:39 -0400 Subject: add docs --- docs/api/request.rst | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'docs/api') diff --git a/docs/api/request.rst b/docs/api/request.rst index 1112ea069..5e52cfd50 100644 --- a/docs/api/request.rst +++ b/docs/api/request.rst @@ -161,6 +161,49 @@ request, the value of this attribute will be ``None``. See :ref:`matched_route`. + .. method:: subrequest(request, use_tweens=False) + + Obtain a response object from the Pyramid application based on + information in the ``request`` object provided. The ``request`` object + must be an object that implements the Pyramid request interface (such + as a :class:`pyramid.request.Request` instance). If ``use_tweens`` is + ``True``, the request will be sent to the :term:`tween` in the tween + stack closest to the request ingress. If ``use_tweens`` is ``False``, + the request will be sent to the main router handler, and no tweens will + be invoked. This isn't *actually* a method of the Request object; it's + a callable added when the Pyramid router is invoked, or when a + subrequest is invoked. This function also: + + - manages the threadlocal stack (so that + :func:`~pyramid.threadlocal.get_current_request` and + :func:`~pyramid.threadlocal.get_current_registry` work during a + request) + + - Adds a ``registry`` attribute (the current Pyramid registry) and a + ``subrequest`` attribute (a callable) to the request object it's + handed. + + - sets request extensions (such as those added via + :meth:`~pyramid.config.Configurator.add_request_method` or + :meth:`~pyramid.config.Configurator.set_request_property`) on the + request it's passed. + + - causes a :class:`~pyramid.event.NewRequest` event to be sent at the + beginning of request processing. + + - causes a :class:`~pyramid.event.ContextFound` event to be sent + when a context resource is found. + + - causes a :class:`~pyramid.event.NewResponse` event to be sent when + the Pyramid application returns a response. + + - Calls any :term:`response callback` functions defined within the + request's lifetime if a response is obtained from the Pyramid + application. + + - Calls any :term:`finished callback` functions defined within the + request's lifetime. + .. automethod:: add_response_callback .. automethod:: add_finished_callback -- cgit v1.2.3 From 37d2c224b804dfebe9ee217c7a536364eacdee15 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 16 Sep 2012 03:25:17 -0400 Subject: docs and test --- docs/api/request.rst | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'docs/api') diff --git a/docs/api/request.rst b/docs/api/request.rst index 5e52cfd50..603807abe 100644 --- a/docs/api/request.rst +++ b/docs/api/request.rst @@ -163,6 +163,10 @@ .. method:: subrequest(request, use_tweens=False) + .. warning:: + + This API was added in Pyramid 1.4a1. + Obtain a response object from the Pyramid application based on information in the ``request`` object provided. The ``request`` object must be an object that implements the Pyramid request interface (such @@ -204,6 +208,8 @@ - Calls any :term:`finished callback` functions defined within the request's lifetime. + See also :ref:`subrequest_chapter`. + .. automethod:: add_response_callback .. automethod:: add_finished_callback -- cgit v1.2.3 From 64452edb014423054d1bbc0bb3ed8a3e47b6f611 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 16 Sep 2012 03:54:08 -0400 Subject: rename subrequest to invoke_subrequest --- docs/api/request.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/api') diff --git a/docs/api/request.rst b/docs/api/request.rst index 603807abe..1718d0743 100644 --- a/docs/api/request.rst +++ b/docs/api/request.rst @@ -161,7 +161,7 @@ request, the value of this attribute will be ``None``. See :ref:`matched_route`. - .. method:: subrequest(request, use_tweens=False) + .. method:: invoke_subrequest(request, use_tweens=False) .. warning:: @@ -184,7 +184,7 @@ request) - Adds a ``registry`` attribute (the current Pyramid registry) and a - ``subrequest`` attribute (a callable) to the request object it's + ``invoke_subrequest`` attribute (a callable) to the request object it's handed. - sets request extensions (such as those added via -- cgit v1.2.3 From 7259e7e9f3d8f8eb70bcf782f622f8613f99a51d Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 16 Sep 2012 13:04:14 -0400 Subject: make use_tweens=True the default, add some more tests --- docs/api/request.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'docs/api') diff --git a/docs/api/request.rst b/docs/api/request.rst index 1718d0743..8af81cdac 100644 --- a/docs/api/request.rst +++ b/docs/api/request.rst @@ -161,7 +161,7 @@ request, the value of this attribute will be ``None``. See :ref:`matched_route`. - .. method:: invoke_subrequest(request, use_tweens=False) + .. method:: invoke_subrequest(request, use_tweens=True) .. warning:: @@ -174,9 +174,9 @@ ``True``, the request will be sent to the :term:`tween` in the tween stack closest to the request ingress. If ``use_tweens`` is ``False``, the request will be sent to the main router handler, and no tweens will - be invoked. This isn't *actually* a method of the Request object; it's - a callable added when the Pyramid router is invoked, or when a - subrequest is invoked. This function also: + be invoked. + + This function also: - manages the threadlocal stack (so that :func:`~pyramid.threadlocal.get_current_request` and @@ -208,7 +208,11 @@ - Calls any :term:`finished callback` functions defined within the request's lifetime. - See also :ref:`subrequest_chapter`. + ``invoke_subrequest`` isn't *actually* a method of the Request object; + it's a callable added when the Pyramid router is invoked, or when a + subrequest is invoked. This means that it's not available for use on a + request provided by e.g. the ``pshell`` environment. For more + information, see :ref:`subrequest_chapter`. .. automethod:: add_response_callback -- cgit v1.2.3 From db2a03786ec76f2c6b7eaebb6f1b7c8b844d8c82 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 16 Sep 2012 22:32:26 -0400 Subject: make use_tweens=False the default --- docs/api/request.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'docs/api') diff --git a/docs/api/request.rst b/docs/api/request.rst index 8af81cdac..3a1439874 100644 --- a/docs/api/request.rst +++ b/docs/api/request.rst @@ -161,7 +161,7 @@ request, the value of this attribute will be ``None``. See :ref:`matched_route`. - .. method:: invoke_subrequest(request, use_tweens=True) + .. method:: invoke_subrequest(request, use_tweens=False) .. warning:: @@ -198,6 +198,9 @@ - causes a :class:`~pyramid.event.ContextFound` event to be sent when a context resource is found. + - Ensures that the user implied by the request passed has the necessary + authorization to invoke view callable before calling it. + - causes a :class:`~pyramid.event.NewResponse` event to be sent when the Pyramid application returns a response. -- cgit v1.2.3 From 68c00de2f71f95571c1876d024c9ad5d4dfeec2c Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 19 Sep 2012 03:30:18 -0400 Subject: add check_csrf convenience function --- docs/api/session.rst | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs/api') diff --git a/docs/api/session.rst b/docs/api/session.rst index 44b4bd860..31bc196ad 100644 --- a/docs/api/session.rst +++ b/docs/api/session.rst @@ -11,4 +11,6 @@ .. autofunction:: signed_deserialize + .. autofunction:: check_csrf_token + -- cgit v1.2.3