| Age | Commit message (Collapse) | Author |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cleanup callback has a "request" parameter (and not "_")
cleanup callback know (since 1.5) if an exception occurred or not (to commit or rollback)
(same as #1302 on 1.5)
|
|
|
|
remember_userid/forget_userid methods from request
|
|
|
|
policies/processes
|
|
callbacks are executed. It previously executed before response callbacks
were executed. Rationale: it's more useful to be able to inspect the response
after response callbacks have done their jobs instead of before.
Closes #1116.
|
|
|
|
Request.localizer, fix docs; closes #1099
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--------
- Add ``pyramid.config.Configurator.add_resource_url_adapter`` API method.
See the Hooks narrative documentation section entitled "Changing How
pyramid.request.Request.resource_url Generates a URL" for more information.
This is not a new feature, it just provides an API for adding a resource
url adapter without needing to use the ZCA API.
- A new interface was added: ``pyramid.interfaces.IResourceURL``. An adapter
implementing its interface can be used to override resource URL generation
when ``request.resource_url`` is called. This interface replaces the
now-deprecated ``pyramid.interfaces.IContextURL`` interface.
- The dictionary passed to a resource's ``__resource_url__`` method (see
"Overriding Resource URL Generation" in the "Resources" chapter) now
contains an ``app_url`` key, representing the application URL generated
during ``request.resource_url``. It represents a potentially customized
URL prefix, containing potentially custom scheme, host and port information
passed by the user to ``request.resource_url``. It should be used instead
of ``request.application_url`` where necessary.
- The ``request.resource_url`` API now accepts these arguments: ``app_url``,
``scheme``, ``host``, and ``port``. The app_url argument can be used to
replace the URL prefix wholesale during url generation. The ``scheme``,
``host``, and ``port`` arguments can be used to replace the respective
default values of ``request.application_url`` partially.
- A new API named ``request.resource_path`` now exists. It works like
``request.resource_url`` but produces a relative URL rather than an
absolute one.
- The ``request.route_url`` API now accepts these arguments: ``_app_url``,
``_scheme``, ``_host``, and ``_port``. The ``_app_url`` argument can be
used to replace the URL prefix wholesale during url generation. The
``_scheme``, ``_host``, and ``_port`` arguments can be used to replace the
respective default values of ``request.application_url`` partially.
Backwards Incompatibilities
---------------------------
- The ``pyramid.interfaces.IContextURL`` interface has been deprecated.
People have been instructed to use this to register a resource url adapter
in the "Hooks" chapter to use to influence ``request.resource_url`` URL
generation for resources found via custom traversers since Pyramid 1.0.
The interface still exists and registering such an adapter still works, but
this interface will be removed from the software after a few major Pyramid
releases. You should replace it with an equivalent
``pyramid.interfaces.IResourceURL`` adapter, registered using the new
``pyramid.config.Configurator.add_resource_url_adapter`` API. A
deprecation warning is now emitted when a
``pyramid.interfaces.IContextURL`` adapter is found when
``request.resource_url`` is called.
Misc
----
- Change ``set_traverser`` API name to ``add_traverser``.
Ref #438.
|
|
|
|
|
|
|
|
- New function in ``pyramid.url``: ``current_route_path``.
|
|
will be ``None`` until an exception is caught by the Pyramid router, after
which it will be the result of ``sys.exc_info()``.
|
|
|
|
used to wrap the found view callable before it is called by Pyramid's
router. This is a feature usually only used by framework extensions, to
provide, for example, view timing support.
A view wrapper factory must be a callable which accepts three arguments:
``view_callable``, ``request``, and ``exc``. It must return a view
callable. The view callable returned by the factory must implement the
``context, request`` view callable calling convention. For example::
import time
def wrapper_factory(view_callable, request, exc):
def wrapper(context, request):
start = time.time()
result = view_callable(context, request)
end = time.time()
request.view_timing = end - start
return result
return wrapper
The ``view_callable`` argument to the factory will be the view callable
found by Pyramid via view lookup. The ``request`` argument to the factory
will be the current request. The ``exc`` argument to the factory will be
an Exception object if the found view is an exception view; it will be
``None`` otherwise.
View wrappers only last for the duration of a single request. You can add
such a factory for every request by using the
``pyramid.events.NewRequest`` subscriber::
from pyramid.events import subscriber, NewRequest
@subscriber(NewRequest)
def newrequest(event):
event.request.add_view_wrapper(wrapper_factory)
If more than one view wrapper is registered during a single request,
a 'later' view wrapper factory will be called with the result of its
directly former view wrapper factory as its ``view_callable``
argument; this chain will be returned to Pyramid as a single view
callable.
|
|
|
|
``application/json``, this attribute will contain the JSON-decoded
variant of the request body. If the request's ``content_type`` is not
``application/json``, this attribute will be ``None``.
|
|
abstraction.
- It is now possible to return an arbitrary object from a Pyramid view
callable even if a renderer is not used, as long as a suitable adapter to
``pyramid.interfaces.IResponse`` is registered for the type of the returned
object. See the section in the Hooks chapter of the documentation entitled
"Changing How Pyramid Treats View Responses".
- The Pyramid router now, by default, expects response objects returned from
view callables to implement the ``pyramid.interfaces.IResponse`` interface.
Unlike the Pyramid 1.0 version of this interface, objects which implement
IResponse now must define a ``__call__`` method that accepts ``environ``
and ``start_response``, and which returns an ``app_iter`` iterable, among
other things. Previously, it was possible to return any object which had
the three WebOb ``app_iter``, ``headerlist``, and ``status`` attributes as
a response, so this is a backwards incompatibility. It is possible to get
backwards compatibility back by registering an adapter to IResponse from
the type of object you're now returning from view callables. See the
section in the Hooks chapter of the documentation entitled "Changing How
Pyramid Treats View Responses".
- The ``pyramid.interfaces.IResponse`` interface is now much more extensive.
Previously it defined only ``app_iter``, ``status`` and ``headerlist``; now
it is basically intended to directly mirror the ``webob.Response`` API,
which has many methods and attributes.
- Documentation changes to support above.
|
|
interface API documentation.
|
|
|
|
|
|
|
|
``request.response_content_type = 'foo'``. Assignments and mutations of
the following request attributes that were considered by the framework for
response influence are now deprecated: ``response_content_type``,
``response_headerlist``, ``response_status``, ``response_charset``, and
``response_cache_for``. Instead of assigning these to the request object
for detection by the rendering machinery, users should use the appropriate
API of the Response object created by accessing ``request.response``
(e.g. ``request.response_content_type = 'abc'`` ->
``request.response.content_type = 'abc'``).
- Custom request objects are now required to have a ``response`` attribute
(or reified property) if they are meant to be used with renderers. This
``response`` attribute should be an instance of the class
``pyramid.response.Response``.
- The JSON and string renderer factories now use
``request.response.content_type`` rather than
``request.response_content_type``. They determine whether they should set
the content type of the response by comparing the response's content type
against the default (usually ``text/html``); if the content type is not the
default, the renderer changes the content type (to ``application/json`` or
``text/plain`` for JSON and string renderers respectively).
- Made it possible to assign to and delete
``pyramid.testing.DummyRequest.registry`` (bugfix).
|
|
|
|
``route_path``, ``route_url``, and ``static_url`` methods to
``pyramid.request.Request`` API docs.
|
|
|
|
``route_url``. These are simple passthroughs for their respective
functions in ``pyramid.url``.
- Documented the ``matchdict`` and ``matched_route`` attributes of the
request object in the Request API documentation.
|