56
56
as_sorted_tuple ,
57
57
is_nonstr_iter ,
58
58
)
59
- from pyramid .view import AppendSlashNotFoundViewFactory
59
+ from pyramid .view import LIFT , AppendSlashNotFoundViewFactory
60
60
import pyramid .viewderivers
61
61
from pyramid .viewderivers import (
62
62
INGRESS ,
@@ -572,7 +572,9 @@ def wrapper(context, request):
572
572
name
573
573
574
574
The :term:`view name`. Read :ref:`traversal_chapter` to
575
- understand the concept of a view name.
575
+ understand the concept of a view name. When :term:`view` is a class,
576
+ the sentinel value view.LIFT will cause the :term:`attr` value to be
577
+ copied to name (useful with view_defaults to reduce boilerplate).
576
578
577
579
context
578
580
@@ -587,6 +589,9 @@ def wrapper(context, request):
587
589
to ``add_view`` as ``for_`` (an older, still-supported
588
590
spelling). If the view should *only* match when handling
589
591
exceptions, then set the ``exception_only`` to ``True``.
592
+ When :term:`view` is a class, the sentinel value view.LIFT here
593
+ will cause the :term:`context` value to be set at scan time
594
+ (useful in conjunction with venusian :term:`lift`).
590
595
591
596
route_name
592
597
@@ -815,6 +820,14 @@ def wrapper(context, request):
815
820
containment = self .maybe_dotted (containment )
816
821
mapper = self .maybe_dotted (mapper )
817
822
823
+ if inspect .isclass (view ):
824
+ if context is LIFT :
825
+ context = view
826
+ if name is LIFT :
827
+ name = attr
828
+ elif LIFT in (context , name ):
829
+ raise ValueError ('LIFT is only allowed when view is a class' )
830
+
818
831
if is_nonstr_iter (decorator ):
819
832
decorator = combine_decorators (* map (self .maybe_dotted , decorator ))
820
833
else :
0 commit comments