diff options
31 files changed, 360 insertions, 253 deletions
diff --git a/docs/designdefense.rst b/docs/designdefense.rst index d1b969ff4..d71f9af7f 100644 --- a/docs/designdefense.rst +++ b/docs/designdefense.rst @@ -245,7 +245,9 @@ its API is much nicer than the ZCA registry API, work on it was largely abandoned and it is not used in :app:`Pyramid`. We continued to use a ZCA registry within :app:`Pyramid` because it ultimately proved a better fit. -.. note:: We continued using ZCA registry rather than disusing it in +.. note:: + + We continued using ZCA registry rather than disusing it in favor of using the registry implementation in :mod:`repoze.component` largely because the ZCA concept of interfaces provides for use of an interface hierarchy, which is diff --git a/docs/index.rst b/docs/index.rst index d7f2f4fb6..25aaab7af 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -227,3 +227,12 @@ Index and Glossary * :ref:`glossary` * :ref:`genindex` * :ref:`search` + + +.. add glossary in hidden toc tree so it does not complain its not included + +.. toctree:: + :hidden: + + glossary + diff --git a/docs/narr/assets.rst b/docs/narr/assets.rst index 93b03fbc9..cd76f7b60 100644 --- a/docs/narr/assets.rst +++ b/docs/narr/assets.rst @@ -102,7 +102,9 @@ directory on a filesystem to an application user's browser. Use the mechanism makes a directory of static files available at a name relative to the application root URL, e.g. ``/static`` or as an external URL. -.. note:: :meth:`~pyramid.config.Configurator.add_static_view` cannot serve a +.. note:: + + :meth:`~pyramid.config.Configurator.add_static_view` cannot serve a single file, nor can it serve a directory of static files directly relative to the root URL of a :app:`Pyramid` application. For these features, see :ref:`advanced_static`. @@ -312,7 +314,9 @@ instance of this class is actually used by the :meth:`~pyramid.config.Configurator.add_static_view` configuration method, so its behavior is almost exactly the same once it's configured. -.. warning:: The following example *will not work* for applications that use +.. warning:: + + The following example *will not work* for applications that use :term:`traversal`, it will only work if you use :term:`URL dispatch` exclusively. The root-relative route we'll be registering will always be matched before traversal takes place, subverting any views registered via diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst index 4afc0506b..3ab82ecf7 100644 --- a/docs/narr/hooks.rst +++ b/docs/narr/hooks.rst @@ -55,7 +55,9 @@ Here's some sample code that implements a minimal NotFound view callable: def notfound_view(request): return HTTPNotFound() -.. note:: When a NotFound view callable is invoked, it is passed a +.. note:: + + When a NotFound view callable is invoked, it is passed a :term:`request`. The ``exception`` attribute of the request will be an instance of the :exc:`~pyramid.httpexceptions.HTTPNotFound` exception that caused the not found view to be called. The value of @@ -64,7 +66,9 @@ Here's some sample code that implements a minimal NotFound view callable: ``pyramid.debug_notfound`` environment setting is true than it is when it is false. -.. warning:: When a NotFound view callable accepts an argument list as +.. warning:: + + When a NotFound view callable accepts an argument list as described in :ref:`request_and_context_view_definitions`, the ``context`` passed as the first argument to the view callable will be the :exc:`~pyramid.httpexceptions.HTTPNotFound` exception instance. If @@ -121,7 +125,9 @@ Here's some sample code that implements a minimal forbidden view: def forbidden_view(request): return Response('forbidden') -.. note:: When a forbidden view callable is invoked, it is passed a +.. note:: + + When a forbidden view callable is invoked, it is passed a :term:`request`. The ``exception`` attribute of the request will be an instance of the :exc:`~pyramid.httpexceptions.HTTPForbidden` exception that caused the forbidden view to be called. The value of @@ -1100,7 +1106,9 @@ in the ``pyramid.tweens`` list will be used as the producer of the effective declared directly "below" it, ad infinitum. The "main" Pyramid request handler is implicit, and always "at the bottom". -.. note:: Pyramid's own :term:`exception view` handling logic is implemented +.. note:: + + Pyramid's own :term:`exception view` handling logic is implemented as a tween factory function: :func:`pyramid.tweens.excview_tween_factory`. If Pyramid exception view handling is desired, and tween factories are specified via the ``pyramid.tweens`` configuration setting, the diff --git a/docs/narr/i18n.rst b/docs/narr/i18n.rst index aef9b59ab..bac86e982 100644 --- a/docs/narr/i18n.rst +++ b/docs/narr/i18n.rst @@ -518,7 +518,9 @@ negotiator is registered. def aview(request): locale = get_localizer(request) -.. note:: If you need to create a localizer for a locale use the +.. note:: + + If you need to create a localizer for a locale use the :func:`pyramid.i18n.make_localizer` function. .. index:: @@ -555,7 +557,9 @@ represented by the request. The translation returned from its ``domain`` attribute of the provided translation string as well as the locale of the localizer. -.. note:: If you're using :term:`Chameleon` templates, you don't need +.. note:: + + If you're using :term:`Chameleon` templates, you don't need to pre-translate translation strings this way. See :ref:`chameleon_translation_strings`. diff --git a/docs/narr/install.rst b/docs/narr/install.rst index a1e7ce382..e1b5eb208 100644 --- a/docs/narr/install.rst +++ b/docs/narr/install.rst @@ -229,7 +229,9 @@ following: New python executable in env/bin/python Installing setuptools.............done. -.. warning:: Using ``--no-site-packages`` when generating your +.. warning:: + + Using ``--no-site-packages`` when generating your virtualenv is *very important*. This flag provides the necessary isolation for running the set of packages required by :app:`Pyramid`. If you do not specify ``--no-site-packages``, diff --git a/docs/narr/logging.rst b/docs/narr/logging.rst index 8abcba3c7..3e39151a3 100644 --- a/docs/narr/logging.rst +++ b/docs/narr/logging.rst @@ -7,7 +7,9 @@ Logging :mod:`logging` module. This chapter describes how to configure logging and how to send log messages to loggers that you've configured. -.. warning:: This chapter assumes you've used a :term:`scaffold` to create a +.. warning:: + + This chapter assumes you've used a :term:`scaffold` to create a project which contains ``development.ini`` and ``production.ini`` files which help configure logging. All of the scaffolds which ship along with :app:`Pyramid` do this. If you're not using a scaffold, or if you've used diff --git a/docs/narr/muchadoabouttraversal.rst b/docs/narr/muchadoabouttraversal.rst index 6ad33c1ce..a948e57cc 100644 --- a/docs/narr/muchadoabouttraversal.rst +++ b/docs/narr/muchadoabouttraversal.rst @@ -313,6 +313,8 @@ don't require it, great: stick with :term:`URL dispatch`. But if you're using :app:`Pyramid` and you ever find that you *do* need to support one of these use cases, you'll be glad you have traversal in your toolkit. -.. note:: It is even possible to mix and match :term:`traversal` with +.. note:: + + It is even possible to mix and match :term:`traversal` with :term:`URL dispatch` in the same :app:`Pyramid` application. See the :ref:`hybrid_chapter` chapter for details. diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 10b7a5d04..345672204 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -64,7 +64,9 @@ The included scaffolds are these: URL mapping via :term:`traversal` and persistence via :term:`SQLAlchemy` -.. note:: At this time, each of these scaffolds uses the :term:`Chameleon` +.. note:: + + At this time, each of these scaffolds uses the :term:`Chameleon` templating system, which is incompatible with Jython. To use scaffolds to build applications which will run on Jython, you can try the ``pyramid_jinja2_starter`` scaffold which ships as part of the diff --git a/docs/narr/resources.rst b/docs/narr/resources.rst index b8dc6d857..256f69fc3 100644 --- a/docs/narr/resources.rst +++ b/docs/narr/resources.rst @@ -160,7 +160,9 @@ resource in the resource tree, you will eventually come to the root resource, just like if you keep executing the ``cd ..`` filesystem command, eventually you will reach the filesystem root directory. -.. warning:: If your root resource has a ``__name__`` argument that is not +.. warning:: + + If your root resource has a ``__name__`` argument that is not ``None`` or the empty string, URLs returned by the :func:`~pyramid.request.Request.resource_url` function and paths generated by the :func:`~pyramid.traversal.resource_path` and diff --git a/docs/narr/templates.rst b/docs/narr/templates.rst index 6412c070d..052843a23 100644 --- a/docs/narr/templates.rst +++ b/docs/narr/templates.rst @@ -46,7 +46,9 @@ within the body of a view callable like so: {'foo':1, 'bar':2}, request=request) -.. warning:: Earlier iterations of this documentation +.. warning:: + + Earlier iterations of this documentation (pre-version-1.3) encouraged the application developer to use ZPT-specific APIs such as :func:`pyramid.chameleon_zpt.render_template_to_response` and diff --git a/docs/narr/urldispatch.rst b/docs/narr/urldispatch.rst index a6e46515f..9d5229c70 100644 --- a/docs/narr/urldispatch.rst +++ b/docs/narr/urldispatch.rst @@ -353,7 +353,9 @@ process. Examples of route predicate arguments are ``pattern``, ``xhr``, and Other arguments are ``name`` and ``factory``. These arguments represent neither predicates nor view configuration information. -.. warning:: Some arguments are view-configuration related arguments, such as +.. warning:: + + Some arguments are view-configuration related arguments, such as ``view_renderer``. These only have an effect when the route configuration names a ``view`` and these arguments have been deprecated as of :app:`Pyramid` 1.1. @@ -646,7 +648,9 @@ other non-``name`` and non-``pattern`` arguments to exception to this rule is use of the ``pregenerator`` argument, which is not ignored when ``static`` is ``True``. -.. note:: the ``static`` argument to +.. note:: + + the ``static`` argument to :meth:`~pyramid.config.Configurator.add_route` is new as of :app:`Pyramid` 1.1. @@ -1098,7 +1102,9 @@ permission. Obviously you can do more generic things than inspect the routes match dict to see if the ``article`` argument matches a particular string; our sample ``Article`` factory class is not very ambitious. -.. note:: See :ref:`security_chapter` for more information about +.. note:: + + See :ref:`security_chapter` for more information about :app:`Pyramid` security and ACLs. .. index:: diff --git a/docs/tutorials/wiki/definingviews.rst b/docs/tutorials/wiki/definingviews.rst index 9d783f8cb..ed3a84118 100644 --- a/docs/tutorials/wiki/definingviews.rst +++ b/docs/tutorials/wiki/definingviews.rst @@ -7,7 +7,9 @@ application is typically a simple Python function that accepts two parameters: :term:`context` and :term:`request`. A view callable is assumed to return a :term:`response` object. -.. note:: A :app:`Pyramid` view can also be defined as callable +.. note:: + + A :app:`Pyramid` view can also be defined as callable which accepts *only* a :term:`request` argument. You'll see this one-argument pattern used in other :app:`Pyramid` tutorials and applications. Either calling convention will work in any @@ -253,7 +255,9 @@ the below: .. literalinclude:: src/views/tutorial/templates/view.pt :language: xml -.. note:: The names available for our use in a template are always those that +.. note:: + + The names available for our use in a template are always those that are present in the dictionary returned by the view callable. But our templates make use of a ``request`` object that none of our tutorial views return in their dictionary. This value appears as if "by magic". diff --git a/docs/tutorials/wiki2/definingviews.rst b/docs/tutorials/wiki2/definingviews.rst index 8f6dd6455..234f91246 100644 --- a/docs/tutorials/wiki2/definingviews.rst +++ b/docs/tutorials/wiki2/definingviews.rst @@ -7,7 +7,9 @@ application is typically a simple Python function that accepts a single parameter named :term:`request`. A view callable is assumed to return a :term:`response` object. -.. note:: A :app:`Pyramid` view can also be defined as callable +.. note:: + + A :app:`Pyramid` view can also be defined as callable which accepts *two* arguments: a :term:`context` and a :term:`request`. You'll see this two-argument pattern used in other :app:`Pyramid` tutorials and applications. Either calling diff --git a/pyramid/config/__init__.py b/pyramid/config/__init__.py index a2014b1b5..9effeed17 100644 --- a/pyramid/config/__init__.py +++ b/pyramid/config/__init__.py @@ -140,9 +140,10 @@ class Configurator( same. See :ref:`adding_renderer_globals`. By default, it is ``None``, which means use no renderer globals factory. - .. warning:: as of Pyramid 1.1, ``renderer_globals_factory`` is - deprecated. Instead, use a BeforeRender event subscriber as per - :ref:`beforerender_event`. + .. warning:: + + as of Pyramid 1.1, ``renderer_globals_factory`` is deprecated. Instead, + use a BeforeRender event subscriber as per :ref:`beforerender_event`. If ``default_permission`` is passed, it should be a :term:`permission` string to be used as the default permission for @@ -288,7 +289,7 @@ class Configurator( if debug_logger is None: debug_logger = logging.getLogger(self.package_name) - + registry.registerUtility(debug_logger, IDebugLogger) for name, renderer in DEFAULT_RENDERERS: @@ -361,7 +362,7 @@ class Configurator( tweens = aslist(registry.settings.get('pyramid.tweens', [])) for factory in tweens: self._add_tween(factory, explicit=True) - + includes = aslist(registry.settings.get('pyramid.includes', [])) for inc in includes: self.include(inc) @@ -557,7 +558,7 @@ class Configurator( ``route_prefix``. This can be used to help mount a set of routes at a different location than the included callable's author intended while still maintaining the same route names. For example: - + .. code-block:: python :linenos: @@ -565,7 +566,7 @@ class Configurator( def included(config): config.add_route('show_users', '/show') - + def main(global_config, **settings): config = Configurator() config.include(included, route_prefix='/users') @@ -613,7 +614,7 @@ class Configurator( configurator.basepath = os.path.dirname(sourcefile) configurator.includepath = self.includepath + (spec,) c(configurator) - + def add_directive(self, name, directive, action_wrap=True): """ Add a directive method to the configurator. @@ -636,7 +637,7 @@ class Configurator( discriminators. ``action_wrap`` will cause the directive to be wrapped in a decorator which provides more accurate conflict cause information. - + ``add_directive`` does not participate in conflict detection, and later calls to ``add_directive`` will override earlier calls. """ diff --git a/pyramid/config/factories.py b/pyramid/config/factories.py index 4b3fa5a9d..0e59f9286 100644 --- a/pyramid/config/factories.py +++ b/pyramid/config/factories.py @@ -14,9 +14,11 @@ class FactoriesConfiguratorMixin(object): state. If the ``factory`` argument is ``None`` a default root factory will be registered. - .. note:: Using the ``root_factory`` argument to the - :class:`pyramid.config.Configurator` constructor - can be used to achieve the same purpose. + .. note:: + + Using the ``root_factory`` argument to the + :class:`pyramid.config.Configurator` constructor can be used to + achieve the same purpose. """ factory = self.maybe_dotted(factory) if factory is None: @@ -35,9 +37,11 @@ class FactoriesConfiguratorMixin(object): method is called, the ``session_factory`` argument must be a session factory callable or a :term:`dotted Python name` to that factory. - .. note:: Using the ``session_factory`` argument to the - :class:`pyramid.config.Configurator` constructor - can be used to achieve the same purpose. + .. note:: + + Using the ``session_factory`` argument to the + :class:`pyramid.config.Configurator` constructor can be used to + achieve the same purpose. """ session_factory = self.maybe_dotted(session_factory) def register(): @@ -54,7 +58,9 @@ class FactoriesConfiguratorMixin(object): :class:`pyramid.request.Request` class (particularly ``__call__``, and ``blank``). - .. note:: Using the ``request_factory`` argument to the + .. note:: + + Using the ``request_factory`` argument to the :class:`pyramid.config.Configurator` constructor can be used to achieve the same purpose. """ diff --git a/pyramid/config/i18n.py b/pyramid/config/i18n.py index 0c07ad4f8..6eed99191 100644 --- a/pyramid/config/i18n.py +++ b/pyramid/config/i18n.py @@ -30,9 +30,11 @@ class I18NConfiguratorMixin(object): application. See :ref:`activating_translation` for more information. - .. note:: Using the ``locale_negotiator`` argument to the - :class:`pyramid.config.Configurator` constructor - can be used to achieve the same purpose. + .. note:: + + Using the ``locale_negotiator`` argument to the + :class:`pyramid.config.Configurator` constructor can be used to + achieve the same purpose. """ def register(): self._set_locale_negotiator(negotiator) diff --git a/pyramid/config/rendering.py b/pyramid/config/rendering.py index c652a980c..f70dea118 100644 --- a/pyramid/config/rendering.py +++ b/pyramid/config/rendering.py @@ -39,7 +39,7 @@ class RenderingConfiguratorMixin(object): # if name is None or the empty string, we're trying to register # a default renderer, but registerUtility is too dumb to accept None # as a name - if not name: + if not name: name = '' def register(): self.registry.registerUtility(factory, IRendererFactory, name=name) @@ -61,9 +61,13 @@ class RenderingConfiguratorMixin(object): dictionary, and therefore will be made available to the code which uses the renderer. - .. warning:: This method is deprecated as of Pyramid 1.1. + .. warning:: - .. note:: Using the ``renderer_globals_factory`` argument + This method is deprecated as of Pyramid 1.1. + + .. note:: + + Using the ``renderer_globals_factory`` argument to the :class:`pyramid.config.Configurator` constructor can be used to achieve the same purpose. """ diff --git a/pyramid/config/routes.py b/pyramid/config/routes.py index f89dcdc8d..4008a2e08 100644 --- a/pyramid/config/routes.py +++ b/pyramid/config/routes.py @@ -147,12 +147,14 @@ class RoutesConfiguratorMixin(object): pattern doesn't match the current URL, route matching continues. - .. note:: For backwards compatibility purposes (as of - :app:`Pyramid` 1.0), a ``path`` keyword argument passed - to this function will be used to represent the pattern - value if the ``pattern`` argument is ``None``. If both - ``path`` and ``pattern`` are passed, ``pattern`` wins. - + .. note:: + + For backwards compatibility purposes (as of :app:`Pyramid` 1.0), a + ``path`` keyword argument passed to this function will be used to + represent the pattern value if the ``pattern`` argument is + ``None``. If both ``path`` and ``pattern`` are passed, ``pattern`` + wins. + xhr This value should be either ``True`` or ``False``. If this @@ -249,7 +251,9 @@ class RoutesConfiguratorMixin(object): View-Related Arguments - .. warning:: The arguments described below have been deprecated as of + .. warning:: + + The arguments described below have been deprecated as of :app:`Pyramid` 1.1. *Do not use these for new development; they should only be used to support older code bases which depend upon them.* Use a separate call to @@ -267,7 +271,7 @@ class RoutesConfiguratorMixin(object): view_context .. warning:: Deprecated as of :app:`Pyramid` 1.1. - + A class or an :term:`interface` or :term:`dotted Python name` to the same object which the :term:`context` of the view should match for the view named by the route to be diff --git a/pyramid/config/security.py b/pyramid/config/security.py index 31bf74e7c..935e2fd95 100644 --- a/pyramid/config/security.py +++ b/pyramid/config/security.py @@ -15,10 +15,12 @@ class SecurityConfiguratorMixin(object): of an authentication policy or a :term:`dotted Python name` that points at an instance of an authentication policy. - .. note:: Using the ``authentication_policy`` argument to the - :class:`pyramid.config.Configurator` constructor - can be used to achieve the same purpose. - + .. note:: + + Using the ``authentication_policy`` argument to the + :class:`pyramid.config.Configurator` constructor can be used to + achieve the same purpose. + """ def register(): self._set_authentication_policy(policy) @@ -41,9 +43,11 @@ class SecurityConfiguratorMixin(object): of an authorization policy or a :term:`dotted Python name` that points at an instance of an authorization policy. - .. note:: Using the ``authorization_policy`` argument to the - :class:`pyramid.config.Configurator` constructor - can be used to achieve the same purpose. + .. note:: + + Using the ``authorization_policy`` argument to the + :class:`pyramid.config.Configurator` constructor can be used to + achieve the same purpose. """ def register(): self._set_authorization_policy(policy) @@ -55,7 +59,7 @@ class SecurityConfiguratorMixin(object): 'Cannot configure an authorization policy without ' 'also configuring an authentication policy ' '(use the set_authorization_policy method)') - + # authorization policy used by view config (phase 3) and # authentication policy (phase 2) self.action(IAuthorizationPolicy, register, order=PHASE1_CONFIG) @@ -98,9 +102,11 @@ class SecurityConfiguratorMixin(object): See also :ref:`setting_a_default_permission`. - .. note:: Using the ``default_permission`` argument to the - :class:`pyramid.config.Configurator` constructor - can be used to achieve the same purpose. + .. note:: + + Using the ``default_permission`` argument to the + :class:`pyramid.config.Configurator` constructor can be used to + achieve the same purpose. """ # default permission used during view registration (phase 3) def register(): diff --git a/pyramid/config/util.py b/pyramid/config/util.py index 7ce9adc4f..1e54213ac 100644 --- a/pyramid/config/util.py +++ b/pyramid/config/util.py @@ -258,4 +258,4 @@ def as_sorted_tuple(val): val = (val,) val = tuple(sorted(val)) return val - + diff --git a/pyramid/config/views.py b/pyramid/config/views.py index 703e3cca5..0d29d4331 100644 --- a/pyramid/config/views.py +++ b/pyramid/config/views.py @@ -139,7 +139,7 @@ class ViewDeriver(object): def http_cached_view(self, view): if self.registry.settings.get('prevent_http_cache', False): return view - + seconds = self.kw.get('http_cache') if seconds is None: @@ -365,7 +365,7 @@ class DefaultViewMapper(object): elif self.attr: mapped_view = self.map_nonclass_attr(view) return mapped_view - + def map_class_requestonly(self, view): # its a class that has an __init__ which only accepts request attr = self.attr @@ -713,7 +713,7 @@ class ViewsConfiguratorMixin(object): accept ``(context, request)``. The decorator must return a replacement view callable which also accepts ``(context, request)``. - + mapper A Python object or :term:`dotted Python name` which refers to a @@ -722,7 +722,7 @@ class ViewsConfiguratorMixin(object): plug-point is useful for Pyramid extension developers, but it's not very useful for 'civilians' who are just developing stock Pyramid applications. Pay no attention to the man behind the curtain. - + Predicate Arguments name @@ -1061,16 +1061,17 @@ class ViewsConfiguratorMixin(object): discriminator.extend(sorted(custom_predicates)) discriminator = tuple(discriminator) self.action(discriminator, register) - + def derive_view(self, view, attr=None, renderer=None): """ Create a :term:`view callable` using the function, instance, or class (or :term:`dotted Python name` referring to the same) provided as ``view`` object. - .. warning:: This method is typically only used by :app:`Pyramid` - framework extension authors, not by :app:`Pyramid` application - developers. + .. warning:: + + This method is typically only used by :app:`Pyramid` framework + extension authors, not by :app:`Pyramid` application developers. This is API is useful to framework extenders who create pluggable systems which need to register 'proxy' view @@ -1173,7 +1174,7 @@ class ViewsConfiguratorMixin(object): mapper=mapper, decorator=decorator, http_cache=http_cache) - + return deriver(view) @action_method @@ -1182,11 +1183,12 @@ class ViewsConfiguratorMixin(object): """ Add a default forbidden view to the current configuration state. - .. warning:: This method has been deprecated in :app:`Pyramid` - 1.0. *Do not use it for new development; it should only be - used to support older code bases which depend upon it.* See - :ref:`changing_the_forbidden_view` to see how a forbidden - view should be registered in new projects. + .. warning:: + + This method has been deprecated in :app:`Pyramid` 1.0. *Do not use + it for new development; it should only be used to support older code + bases which depend upon it.* See :ref:`changing_the_forbidden_view` + to see how a forbidden view should be registered in new projects. The ``view`` argument should be a :term:`view callable` or a :term:`dotted Python name` which refers to a view callable. @@ -1222,12 +1224,12 @@ class ViewsConfiguratorMixin(object): """ Add a default not found view to the current configuration state. - .. warning:: This method has been deprecated in - :app:`Pyramid` 1.0. *Do not use it for new development; - it should only be used to support older code bases which - depend upon it.* See :ref:`changing_the_notfound_view` to - see how a not found view should be registered in new - projects. + .. warning:: + + This method has been deprecated in :app:`Pyramid` 1.0. *Do not use + it for new development; it should only be used to support older code + bases which depend upon it.* See :ref:`changing_the_notfound_view` to + see how a not found view should be registered in new projects. The ``view`` argument should be a :term:`view callable` or a :term:`dotted Python name` which refers to a view callable. @@ -1274,7 +1276,9 @@ class ViewsConfiguratorMixin(object): See also :ref:`using_a_view_mapper`. - .. note:: Using the ``default_view_mapper`` argument to the + .. note:: + + Using the ``default_view_mapper`` argument to the :class:`pyramid.config.Configurator` constructor can be used to achieve the same purpose. """ @@ -1483,7 +1487,7 @@ class StaticURLInfo(object): attr = extra.pop('view_attr', None) - # register a route using the computed view, permission, and + # register a route using the computed view, permission, and # pattern, plus any extras passed to us via add_static_view pattern = "%s*subpath" % name # name already ends with slash if config.route_prefix: diff --git a/pyramid/events.py b/pyramid/events.py index 71e923c0f..9473d6330 100644 --- a/pyramid/events.py +++ b/pyramid/events.py @@ -16,7 +16,7 @@ class subscriber(object): For example: .. code-block:: python - + from pyramid.events import NewRequest from pyramid.events import subscriber @@ -26,9 +26,9 @@ class subscriber(object): More than one event type can be passed as a construtor argument. The decorated subscriber will be called for each event type. - + .. code-block:: python - + from pyramid.events import NewRequest, NewResponse from pyramid.events import subscriber @@ -40,7 +40,7 @@ class subscriber(object): the function it decorates is called for every event sent: .. code-block:: python - + from pyramid.events import subscriber @subscriber() @@ -51,7 +51,7 @@ class subscriber(object): against the package or module which contains it, ala: .. code-block:: python - + from pyramid.config import Configurator config = Configurator() config.scan('somepackage_containing_subscribers') @@ -132,17 +132,18 @@ class ContextFound(object): This class implements the :class:`pyramid.interfaces.IContextFound` interface. - .. note:: As of :app:`Pyramid` 1.0, for backwards compatibility - purposes, this event may also be imported as - :class:`pyramid.events.AfterTraversal`. + .. note:: + + As of :app:`Pyramid` 1.0, for backwards compatibility purposes, this + event may also be imported as :class:`pyramid.events.AfterTraversal`. """ implements(IContextFound) def __init__(self, request): self.request = request AfterTraversal = ContextFound # b/c as of 1.0 - -class ApplicationCreated(object): + +class ApplicationCreated(object): """ An instance of this class is emitted as an :term:`event` when the :meth:`pyramid.config.Configurator.make_wsgi_app` is called. The instance has an attribute, ``app``, which is an @@ -150,11 +151,11 @@ class ApplicationCreated(object): This class implements the :class:`pyramid.interfaces.IApplicationCreated` interface. - .. note:: For backwards compatibility purposes, this class can - also be imported as - :class:`pyramid.events.WSGIApplicationCreatedEvent`. This - was the name of the event class before :app:`Pyramid` 1.0. + .. note:: + For backwards compatibility purposes, this class can also be imported as + :class:`pyramid.events.WSGIApplicationCreatedEvent`. This was the name + of the event class before :app:`Pyramid` 1.0. """ implements(IApplicationCreated) def __init__(self, app): diff --git a/pyramid/interfaces.py b/pyramid/interfaces.py index a0f27dd7a..d90f56b75 100644 --- a/pyramid/interfaces.py +++ b/pyramid/interfaces.py @@ -9,7 +9,9 @@ class IContextFound(Interface): documentation attached to :class:`pyramid.events.ContextFound` for more information. - .. note:: For backwards compatibility with versions of + .. note:: + + For backwards compatibility with versions of :app:`Pyramid` before 1.0, this event interface can also be imported as :class:`pyramid.interfaces.IAfterTraversal`. """ @@ -22,7 +24,7 @@ class INewRequest(Interface): begins to process a new request. See the documentation attached to :class:`pyramid.events.NewRequest` for more information.""" request = Attribute('The request object') - + class INewResponse(Interface): """ An event type that is emitted whenever any :app:`Pyramid` view returns a response. See the @@ -38,7 +40,9 @@ class IApplicationCreated(Interface): :class:`pyramid.events.ApplicationCreated` for more information. - .. note:: For backwards compatibility with :app:`Pyramid` + .. note:: + + For backwards compatibility with :app:`Pyramid` versions before 1.0, this interface can also be imported as :class:`pyramid.interfaces.IWSGIApplicationCreatedEvent`. """ @@ -151,7 +155,7 @@ class IResponse(Interface): otherwise they will be preserved.""") content_type_params = Attribute( - """A dictionary of all the parameters in the content type. This is + """A dictionary of all the parameters in the content type. This is not a view, set to change, modifications of the dict would not be applied otherwise.""") @@ -276,18 +280,18 @@ class IDict(Interface): def __setitem__(k, value): """ Set a key/value pair into the dictionary""" - + def __delitem__(k): """ Delete an item from the dictionary which is passed to the renderer as the renderer globals dictionary.""" - + def __getitem__(k): """ Return the value for key ``k`` from the dictionary or raise a KeyError if the key doesn't exist""" def __iter__(): """ Return an iterator over the keys of this dictionary """ - + def get(k, default=None): """ Return the value for key ``k`` from the renderer dictionary, or the default if no such value exists.""" @@ -327,7 +331,7 @@ class IDict(Interface): value into the dictionary under the k name passed. If a value already existed in the dictionary, return it. If a value did not exist in the dictionary, return the default""" - + def update(d): """ Update the renderer dictionary with another dictionary ``d``.""" @@ -341,7 +345,7 @@ class IBeforeRender(IDict): The event object itself provides a dictionary-like interface for adding and removing :term:`renderer globals`. The keys and values of the dictionary are those globals. For example:: - + from repoze.events import subscriber from pyramid.interfaces import IBeforeRender @@ -424,7 +428,7 @@ class IAuthenticationPolicy(Interface): principal named ``principal`` when set in a response. An individual authentication policy and its consumers can decide on the composition and meaning of ``**kw.`` """ - + def forget(request): """ Return a set of headers suitable for 'forgetting' the current user on subsequent requests. """ @@ -435,7 +439,7 @@ class IAuthorizationPolicy(Interface): """ Return ``True`` if any of the ``principals`` is allowed the ``permission`` in the current ``context``, else return ``False`` """ - + def principals_allowed_by_permission(context, permission): """ Return a set of principal identifiers allowed by the ``permission`` in ``context``. This behavior is optional; if you @@ -499,7 +503,7 @@ class IRequestHandler(Interface): The ``request`` argument will be an instance of an object that provides IRequest.""" -IRequest.combined = IRequest # for exception view lookups +IRequest.combined = IRequest # for exception view lookups class IRouteRequest(Interface): """ *internal only* interface used as in a utility lookup to find @@ -614,12 +618,12 @@ class IRouter(Interface): a view registry.""" registry = Attribute( """Component architecture registry local to this application.""") - + class ISettings(Interface): """ Runtime settings utility for pyramid; represents the deployment settings for the application. Implements a mapping interface.""" - + # this interface, even if it becomes unused within Pyramid, is # imported by other packages (such as traversalwrapper) class ILocation(Interface): @@ -749,7 +753,7 @@ class IChameleonTranslate(Interface): class ILocalizer(Interface): """ Localizer for a specific language """ - + class ILocaleNegotiator(Interface): def __call__(request): """ Return a locale name """ diff --git a/pyramid/paster.py b/pyramid/paster.py index b419c1b16..bdf7df109 100644 --- a/pyramid/paster.py +++ b/pyramid/paster.py @@ -56,19 +56,21 @@ def bootstrap(config_uri, request=None): that may be called when your script is complete (it pops a threadlocal stack). - .. note:: Most operations within :app:`Pyramid` expect to be invoked - within the context of a WSGI request, thus it's important when - loading your application to anchor it when executing scripts - and other code that is not normally invoked during active WSGI - requests. - - .. note:: For a complex config file containing multiple :app:`Pyramid` - applications, this function will setup the environment under - the context of the last-loaded :app:`Pyramid` application. You - may load a specific application yourself by using the - lower-level functions :meth:`pyramid.paster.get_app` and - :meth:`pyramid.scripting.prepare` in conjunction with - :attr:`pyramid.config.global_registries`. + .. note:: + + Most operations within :app:`Pyramid` expect to be invoked within the + context of a WSGI request, thus it's important when loading your + application to anchor it when executing scripts and other code that is + not normally invoked during active WSGI requests. + + .. note:: + + For a complex config file containing multiple :app:`Pyramid` + applications, this function will setup the environment under the context + of the last-loaded :app:`Pyramid` application. You may load a specific + application yourself by using the lower-level functions + :meth:`pyramid.paster.get_app` and :meth:`pyramid.scripting.prepare` in + conjunction with :attr:`pyramid.config.global_registries`. ``config_uri`` -- specifies the PasteDeploy config file to use for the interactive shell. The format is ``inifile#name``. If the name is left @@ -300,7 +302,7 @@ class PRoutesCommand(PCommand): def out(self, msg): # pragma: no cover print msg - + def command(self): from pyramid.interfaces import IRouteRequest from pyramid.interfaces import IViewClassifier @@ -359,7 +361,7 @@ class PViewsCommand(PCommand): def out(self, msg): # pragma: no cover print msg - + def _find_multi_routes(self, mapper, request): infos = [] path = request.environ['PATH_INFO'] @@ -390,7 +392,7 @@ class PViewsCommand(PCommand): from pyramid.request import Request from pyramid.traversal import DefaultRootFactory from pyramid.traversal import ResourceTreeTraverser - + q = registry.queryUtility root_factory = q(IRootFactory, default=DefaultRootFactory) routes_mapper = q(IRoutesMapper) @@ -579,7 +581,7 @@ class PTweensCommand(PCommand): using an explicit tweens ordering (will be true when the ``pyramid.tweens`` setting is used) or an implicit tweens ordering (will be true when the ``pyramid.tweens`` setting is *not* used). - + This command accepts one positional argument: ``config_uri`` -- specifies the PasteDeploy config file to use for the diff --git a/pyramid/request.py b/pyramid/request.py index 03717031d..9704a42a4 100644 --- a/pyramid/request.py +++ b/pyramid/request.py @@ -409,7 +409,7 @@ def call_app_with_subpath_as_path_info(request, app): if new_path_info != '/': # don't want a sole double-slash if path_info != '/': # if orig path_info is '/', we're already done if path_info.endswith('/'): - # readd trailing slash stripped by subpath (traversal) + # readd trailing slash stripped by subpath (traversal) # conversion new_path_info += '/' @@ -428,7 +428,7 @@ def call_app_with_subpath_as_path_info(request, app): # to end of script_name while workback and (workback[-1] == ''): workback = workback[:-1] - + new_script_name = '/'.join(workback) new_request = request.copy() diff --git a/pyramid/security.py b/pyramid/security.py index a001f7073..5aed7b5fa 100644 --- a/pyramid/security.py +++ b/pyramid/security.py @@ -109,7 +109,9 @@ def principals_allowed_by_permission(context, permission): :mod:`pyramid.security.Everyone` (the special principal identifier representing all principals). - .. note:: even if an :term:`authorization policy` is in effect, + .. note:: + + even if an :term:`authorization policy` is in effect, some (exotic) authorization policies may not implement the required machinery for this function; those will cause a :exc:`NotImplementedError` exception to be raised when this @@ -192,14 +194,14 @@ def forget(request): return [] else: return policy.forget(request) - + class PermitsResult(int): def __new__(cls, s, *args): inst = int.__new__(cls, cls.boolval) inst.s = s inst.args = args return inst - + @property def msg(self): return self.s % self.args diff --git a/pyramid/static.py b/pyramid/static.py index eeb88bf5c..17a74a16a 100644 --- a/pyramid/static.py +++ b/pyramid/static.py @@ -47,7 +47,7 @@ class _FileResponse(Response): content_length = getsize(path) self.app_iter = _FileIter(open(path, 'rb'), content_length) # assignment of content_length must come after assignment of app_iter - self.content_length = content_length + self.content_length = content_length if cache_max_age is not None: self.cache_expires = cache_max_age @@ -110,13 +110,15 @@ class static_view(object): the static application will consider request.path_info as ``PATH_INFO`` input. By default, this is ``False``. - .. note:: If the ``root_dir`` is relative to a :term:`package`, or - is a :term:`asset specification` the :app:`Pyramid` - :class:`pyramid.config.Configurator` method can be - used to override assets within the named ``root_dir`` - package-relative directory. However, if the ``root_dir`` is - absolute, configuration will not be able to - override the assets it contains. """ + .. note:: + + If the ``root_dir`` is relative to a :term:`package`, or is a + :term:`asset specification` the :app:`Pyramid` + :class:`pyramid.config.Configurator` method can be used to override + assets within the named ``root_dir`` package-relative directory. + However, if the ``root_dir`` is absolute, configuration will not be able + to override the assets it contains. + """ def __init__(self, root_dir, cache_max_age=3600, package_name=None, use_subpath=False, index='index.html'): diff --git a/pyramid/traversal.py b/pyramid/traversal.py index b871b8229..bf2606529 100644 --- a/pyramid/traversal.py +++ b/pyramid/traversal.py @@ -125,26 +125,29 @@ def resource_path(resource, *elements): The ``resource`` passed in *must* be :term:`location`-aware. - .. note:: Each segment in the path string returned will use the - ``__name__`` attribute of the resource it represents within - the resource tree. Each of these segments *should* be a unicode - or string object (as per the contract of - :term:`location`-awareness). However, no conversion or - safety checking of resource names is performed. For - instance, if one of the resources in your tree has a - ``__name__`` which (by error) is a dictionary, the - :func:`pyramid.traversal.resource_path` function will - attempt to append it to a string and it will cause a - :exc:`pyramid.exceptions.URLDecodeError`. - - .. note:: The :term:`root` resource *must* have a ``__name__`` - attribute with a value of either ``None`` or the empty - string for paths to be generated properly. If the root - resource has a non-null ``__name__`` attribute, its name - will be prepended to the generated path rather than a - single leading '/' character. + .. note:: - .. note:: For backwards compatibility purposes, this function can also + Each segment in the path string returned will use the ``__name__`` + attribute of the resource it represents within the resource tree. Each + of these segments *should* be a unicode or string object (as per the + contract of :term:`location`-awareness). However, no conversion or + safety checking of resource names is performed. For instance, if one of + the resources in your tree has a ``__name__`` which (by error) is a + dictionary, the :func:`pyramid.traversal.resource_path` function will + attempt to append it to a string and it will cause a + :exc:`pyramid.exceptions.URLDecodeError`. + + .. note:: + + The :term:`root` resource *must* have a ``__name__`` attribute with a + value of either ``None`` or the empty string for paths to be generated + properly. If the root resource has a non-null ``__name__`` attribute, + its name will be prepended to the generated path rather than a single + leading '/' character. + + .. note:: + + For backwards compatibility purposes, this function can also be imported as ``model_path``, although doing so will cause a deprecation warning to be emitted. """ @@ -298,7 +301,7 @@ def traverse(resource, path): resource = find_root(resource) reg = get_current_registry() - + request_factory = reg.queryUtility(IRequestFactory) if request_factory is None: from pyramid.request import Request # avoid circdep @@ -331,28 +334,30 @@ def resource_path_tuple(resource, *elements): The ``resource`` passed in *must* be :term:`location`-aware. - .. note:: Each segment in the path tuple returned will equal the - ``__name__`` attribute of the resource it represents within - the resource tree. Each of these segments *should* be a unicode - or string object (as per the contract of - :term:`location`-awareness). However, no conversion or - safety checking of resource names is performed. For - instance, if one of the resources in your tree has a - ``__name__`` which (by error) is a dictionary, that - dictionary will be placed in the path tuple; no warning - or error will be given. - - .. note:: The :term:`root` resource *must* have a ``__name__`` - attribute with a value of either ``None`` or the empty - string for path tuples to be generated properly. If - the root resource has a non-null ``__name__`` attribute, - its name will be the first element in the generated - path tuple rather than the empty string. - - .. note:: For backwards compatibility purposes, this function can also be - imported as ``model_path_tuple``, although doing so will cause a - deprecation warning to be emitted. + .. note:: + + Each segment in the path tuple returned will equal the ``__name__`` + attribute of the resource it represents within the resource tree. Each + of these segments *should* be a unicode or string object (as per the + contract of :term:`location`-awareness). However, no conversion or + safety checking of resource names is performed. For instance, if one of + the resources in your tree has a ``__name__`` which (by error) is a + dictionary, that dictionary will be placed in the path tuple; no warning + or error will be given. + + .. note:: + + The :term:`root` resource *must* have a ``__name__`` attribute with a + value of either ``None`` or the empty string for path tuples to be + generated properly. If the root resource has a non-null ``__name__`` + attribute, its name will be the first element in the generated path tuple + rather than the empty string. + + .. note:: + For backwards compatibility purposes, this function can also be imported + as ``model_path_tuple``, although doing so will cause a deprecation + warning to be emitted. """ return tuple(_resource_path_list(resource, *elements)) @@ -457,18 +462,17 @@ def traversal_path(path): (u'archives', u'<unprintable unicode>') - .. note:: This function does not generate the same type of tuples - that :func:`pyramid.traversal.resource_path_tuple` does. - In particular, the leading empty string is not present - in the tuple it returns, unlike tuples returned by - :func:`pyramid.traversal.resource_path_tuple`. As a - result, tuples generated by ``traversal_path`` are not - resolveable by the - :func:`pyramid.traversal.find_resource` API. - ``traversal_path`` is a function mostly used by the - internals of :app:`Pyramid` and by people writing - their own traversal machinery, as opposed to users - writing applications in :app:`Pyramid`. + .. note:: + + This function does not generate the same type of tuples that + :func:`pyramid.traversal.resource_path_tuple` does. In particular, the + leading empty string is not present in the tuple it returns, unlike tuples + returned by :func:`pyramid.traversal.resource_path_tuple`. As a result, + tuples generated by ``traversal_path`` are not resolveable by the + :func:`pyramid.traversal.find_resource` API. ``traversal_path`` is a + function mostly used by the internals of :app:`Pyramid` and by people + writing their own traversal machinery, as opposed to users writing + applications in :app:`Pyramid`. """ if isinstance(path, unicode): path = path.encode('ascii') diff --git a/pyramid/url.py b/pyramid/url.py index a28228290..c2ff43ddd 100644 --- a/pyramid/url.py +++ b/pyramid/url.py @@ -70,13 +70,14 @@ class URLMethodsMixin(object): data is turned into a query string, a leading ``?`` is prepended, and the resulting string is appended to the generated URL. - .. note:: Python data structures that are passed as ``_query`` - which are sequences or dictionaries are turned into a - string under the same rules as when run through - :func:`urllib.urlencode` with the ``doseq`` argument - equal to ``True``. This means that sequences can be - passed as values, and a k=v pair will be placed into the - query string for each value. + .. note:: + + Python data structures that are passed as ``_query`` which are + sequences or dictionaries are turned into a string under the same + rules as when run through :func:`urllib.urlencode` with the ``doseq`` + argument equal to ``True``. This means that sequences can be passed + as values, and a k=v pair will be placed into the query string for + each value. If a keyword argument ``_anchor`` is present, its string representation will be used as a named anchor in the generated URL @@ -84,11 +85,12 @@ class URLMethodsMixin(object): ``http://example.com/route/url``, the resulting generated URL will be ``http://example.com/route/url#foo``). - .. note:: If ``_anchor`` is passed as a string, it should be UTF-8 - encoded. If ``_anchor`` is passed as a Unicode object, it - will be converted to UTF-8 before being appended to the - URL. The anchor value is not quoted in any way before - being appended to the generated URL. + .. note:: + + If ``_anchor`` is passed as a string, it should be UTF-8 encoded. If + ``_anchor`` is passed as a Unicode object, it will be converted to + UTF-8 before being appended to the URL. The anchor value is not + quoted in any way before being appended to the generated URL. If both ``_anchor`` and ``_query`` are specified, the anchor element will always follow the query element, @@ -177,13 +179,14 @@ class URLMethodsMixin(object): Will return the string ``/1/2``. - .. note:: Calling ``request.route_path('route')`` is the same as - calling ``request.route_url('route', - _app_url=request.script_name)``. - :meth:`pyramid.request.Request.route_path` is, in fact, - implemented in terms of `:meth:`pyramid.request.Request.route_url` - in just this way. As a result, any ``_app_url`` passed within the - ``**kw`` values to ``route_path`` will be ignored. + .. note:: + + Calling ``request.route_path('route')`` is the same as calling + ``request.route_url('route', _app_url=request.script_name)``. + :meth:`pyramid.request.Request.route_path` is, in fact, implemented + in terms of `:meth:`pyramid.request.Request.route_url` in just this + way. As a result, any ``_app_url`` passed within the ``**kw`` values + to ``route_path`` will be ignored. """ kw['_app_url'] = self.script_name return self.route_url(route_name, *elements, **kw) @@ -238,13 +241,14 @@ class URLMethodsMixin(object): into a query string, a leading ``?`` is prepended, and the resulting string is appended to the generated URL. - .. note:: Python data structures that are passed as ``query`` which - are sequences or dictionaries are turned into a string - under the same rules as when run through - :func:`urllib.urlencode` with the ``doseq`` argument equal - to ``True``. This means that sequences can be passed as - values, and a k=v pair will be placed into the query string - for each value. + .. note:: + + Python data structures that are passed as ``query`` which are + sequences or dictionaries are turned into a string under the same + rules as when run through :func:`urllib.urlencode` with the ``doseq`` + argument equal to ``True``. This means that sequences can be passed + as values, and a k=v pair will be placed into the query string for + each value. If a keyword argument ``anchor`` is present, its string representation will be used as a named anchor in the generated URL @@ -252,11 +256,12 @@ class URLMethodsMixin(object): ``http://example.com/resource/url``, the resulting generated URL will be ``http://example.com/resource/url#foo``). - .. note:: If ``anchor`` is passed as a string, it should be UTF-8 - encoded. If ``anchor`` is passed as a Unicode object, it - will be converted to UTF-8 before being appended to the - URL. The anchor value is not quoted in any way before - being appended to the generated URL. + .. note:: + + If ``anchor`` is passed as a string, it should be UTF-8 encoded. If + ``anchor`` is passed as a Unicode object, it will be converted to + UTF-8 before being appended to the URL. The anchor value is not + quoted in any way before being appended to the generated URL. If both ``anchor`` and ``query`` are specified, the anchor element will always follow the query element, @@ -267,19 +272,24 @@ class URLMethodsMixin(object): the base resource which is operated upon by this function. See also :ref:`overriding_resource_url_generation`. - .. note:: If the :term:`resource` used is the result of a - :term:`traversal`, it must be :term:`location`-aware. The - resource can also be the context of a :term:`URL dispatch`; - contexts found this way do not need to be location-aware. + .. note:: + + If the :term:`resource` used is the result of a :term:`traversal`, it + must be :term:`location`-aware. The resource can also be the context + of a :term:`URL dispatch`; contexts found this way do not need to be + location-aware. + + .. note:: + + If a 'virtual root path' is present in the request environment (the + value of the WSGI environ key ``HTTP_X_VHM_ROOT``), and the resource + was obtained via :term:`traversal`, the URL path will not include the + virtual root prefix (it will be stripped off the left hand side of + the generated URL). - .. note:: If a 'virtual root path' is present in the request - environment (the value of the WSGI environ key - ``HTTP_X_VHM_ROOT``), and the resource was obtained via - :term:`traversal`, the URL path will not include the - virtual root prefix (it will be stripped off the left hand - side of the generated URL). + .. note:: - .. note:: For backwards compatibility purposes, this method is also + For backwards compatibility purposes, this method is also aliased as the ``model_url`` method of request. """ try: @@ -310,7 +320,7 @@ class URLMethodsMixin(object): suffix = '' return resource_url + suffix + qs + anchor - + model_url = resource_url # b/w compat forever def static_url(self, path, **kw): @@ -380,14 +390,14 @@ class URLMethodsMixin(object): /static/foo.css - .. note:: Calling ``request.static_path(apath)`` is the same - as calling ``request.static_url(apath, - _app_url=request.script_name)``. - :meth:`pyramid.request.Request.static_path` is, in fact, - implemented in terms of - `:meth:`pyramid.request.Request.static_url` in just this - way. As a result, any ``_app_url`` passed within the ``**kw`` - values to ``static_path`` will be ignored. + .. note:: + + Calling ``request.static_path(apath)`` is the same as calling + ``request.static_url(apath, _app_url=request.script_name)``. + :meth:`pyramid.request.Request.static_path` is, in fact, implemented + in terms of `:meth:`pyramid.request.Request.static_url` in just this + way. As a result, any ``_app_url`` passed within the ``**kw`` values + to ``static_path`` will be ignored. """ if not os.path.isabs(path): if not ':' in path: @@ -478,7 +488,9 @@ class URLMethodsMixin(object): Will return the string ``/1/2``. - .. note:: Calling ``request.current_route_path('route')`` is the same + .. note:: + + Calling ``request.current_route_path('route')`` is the same as calling ``request.current_route_url('route', _app_url=request.script_name)``. :meth:`pyramid.request.Request.current_route_path` is, in fact, @@ -489,8 +501,8 @@ class URLMethodsMixin(object): """ kw['_app_url'] = self.script_name return self.current_route_url(*elements, **kw) - - + + def route_url(route_name, request, *elements, **kw): """ This is a backwards compatibility function. Its result is the same as diff --git a/pyramid/view.py b/pyramid/view.py index 8b8ac58ce..6046408f6 100644 --- a/pyramid/view.py +++ b/pyramid/view.py @@ -15,7 +15,7 @@ from pyramid.threadlocal import get_current_registry _marker = object() -class static(static_view): +class static(static_view): """ Backwards compatibility alias for :class:`pyramid.static.static_view`; it overrides that class' constructor to pass ``use_subpath=True`` by default. This class is deprecated as of @@ -301,7 +301,9 @@ def is_response(ob): """ Return ``True`` if ``ob`` implements the interface implied by :ref:`the_response`. ``False`` if not. - .. warning:: This function is deprecated as of :app:`Pyramid` 1.1. New + .. warning:: + + This function is deprecated as of :app:`Pyramid` 1.1. New code should not use it. Instead, new code should use the :func:`pyramid.request.Request.is_response` method.""" if ( hasattr(ob, 'app_iter') and hasattr(ob, 'headerlist') and |
