@@ -478,8 +478,11 @@ def add_url_rule(
478
478
provide_automatic_options : t .Optional [bool ] = None ,
479
479
** options : t .Any ,
480
480
) -> None :
481
- """Like :meth:`Flask.add_url_rule` but for a blueprint. The endpoint for
482
- the :func:`url_for` function is prefixed with the name of the blueprint.
481
+ """Register a URL rule with the blueprint. See :meth:`.Flask.add_url_rule` for
482
+ full documentation.
483
+
484
+ The URL rule is prefixed with the blueprint's URL prefix. The endpoint name,
485
+ used with :func:`url_for`, is prefixed with the blueprint's name.
483
486
"""
484
487
if endpoint and "." in endpoint :
485
488
raise ValueError ("'endpoint' may not contain a dot '.' character." )
@@ -501,8 +504,8 @@ def add_url_rule(
501
504
def app_template_filter (
502
505
self , name : t .Optional [str ] = None
503
506
) -> t .Callable [[T_template_filter ], T_template_filter ]:
504
- """Register a custom template filter, available application wide. Like
505
- :meth:`Flask.template_filter` but for a blueprint .
507
+ """Register a template filter, available in any template rendered by the
508
+ application. Equivalent to :meth:`. Flask.template_filter`.
506
509
507
510
:param name: the optional name of the filter, otherwise the
508
511
function name will be used.
@@ -518,9 +521,9 @@ def decorator(f: T_template_filter) -> T_template_filter:
518
521
def add_app_template_filter (
519
522
self , f : ft .TemplateFilterCallable , name : t .Optional [str ] = None
520
523
) -> None :
521
- """Register a custom template filter, available application wide. Like
522
- :meth:`Flask.add_template_filter` but for a blueprint. Works exactly
523
- like the :meth:`app_template_filter` decorator .
524
+ """Register a template filter, available in any template rendered by the
525
+ application. Works like the :meth:`app_template_filter` decorator. Equivalent to
526
+ :meth:`.Flask.add_template_filter` .
524
527
525
528
:param name: the optional name of the filter, otherwise the
526
529
function name will be used.
@@ -535,8 +538,8 @@ def register_template(state: BlueprintSetupState) -> None:
535
538
def app_template_test (
536
539
self , name : t .Optional [str ] = None
537
540
) -> t .Callable [[T_template_test ], T_template_test ]:
538
- """Register a custom template test, available application wide. Like
539
- :meth:`Flask.template_test` but for a blueprint .
541
+ """Register a template test, available in any template rendered by the
542
+ application. Equivalent to :meth:`. Flask.template_test`.
540
543
541
544
.. versionadded:: 0.10
542
545
@@ -554,9 +557,9 @@ def decorator(f: T_template_test) -> T_template_test:
554
557
def add_app_template_test (
555
558
self , f : ft .TemplateTestCallable , name : t .Optional [str ] = None
556
559
) -> None :
557
- """Register a custom template test, available application wide. Like
558
- :meth:`Flask.add_template_test` but for a blueprint. Works exactly
559
- like the :meth:`app_template_test` decorator .
560
+ """Register a template test, available in any template rendered by the
561
+ application. Works like the :meth:`app_template_test` decorator. Equivalent to
562
+ :meth:`.Flask.add_template_test` .
560
563
561
564
.. versionadded:: 0.10
562
565
@@ -573,8 +576,8 @@ def register_template(state: BlueprintSetupState) -> None:
573
576
def app_template_global (
574
577
self , name : t .Optional [str ] = None
575
578
) -> t .Callable [[T_template_global ], T_template_global ]:
576
- """Register a custom template global, available application wide. Like
577
- :meth:`Flask.template_global` but for a blueprint .
579
+ """Register a template global, available in any template rendered by the
580
+ application. Equivalent to :meth:`. Flask.template_global`.
578
581
579
582
.. versionadded:: 0.10
580
583
@@ -592,9 +595,9 @@ def decorator(f: T_template_global) -> T_template_global:
592
595
def add_app_template_global (
593
596
self , f : ft .TemplateGlobalCallable , name : t .Optional [str ] = None
594
597
) -> None :
595
- """Register a custom template global, available application wide. Like
596
- :meth:`Flask.add_template_global` but for a blueprint. Works exactly
597
- like the :meth:`app_template_global` decorator .
598
+ """Register a template global, available in any template rendered by the
599
+ application. Works like the :meth:`app_template_global` decorator. Equivalent to
600
+ :meth:`.Flask.add_template_global` .
598
601
599
602
.. versionadded:: 0.10
600
603
@@ -609,8 +612,8 @@ def register_template(state: BlueprintSetupState) -> None:
609
612
610
613
@setupmethod
611
614
def before_app_request (self , f : T_before_request ) -> T_before_request :
612
- """Like :meth:`Flask. before_request`. Such a function is executed
613
- before each request, even if outside of a blueprint .
615
+ """Like :meth:`before_request`, but before every request, not only those handled
616
+ by the blueprint. Equivalent to :meth:`.Flask.before_request` .
614
617
"""
615
618
self .record_once (
616
619
lambda s : s .app .before_request_funcs .setdefault (None , []).append (f )
@@ -621,8 +624,8 @@ def before_app_request(self, f: T_before_request) -> T_before_request:
621
624
def before_app_first_request (
622
625
self , f : T_before_first_request
623
626
) -> T_before_first_request :
624
- """Like :meth:`Flask.before_first_request`. Such a function is
625
- executed before the first request to the application .
627
+ """Register a function to run before the first request to the application is
628
+ handled by the worker. Equivalent to :meth:`.Flask.before_first_request` .
626
629
627
630
.. deprecated:: 2.2
628
631
Will be removed in Flask 2.3. Run setup code when creating
@@ -642,8 +645,8 @@ def before_app_first_request(
642
645
643
646
@setupmethod
644
647
def after_app_request (self , f : T_after_request ) -> T_after_request :
645
- """Like :meth:`Flask. after_request` but for a blueprint. Such a function
646
- is executed after each request, even if outside of the blueprint .
648
+ """Like :meth:`after_request`, but after every request, not only those handled
649
+ by the blueprint. Equivalent to :meth:`.Flask.after_request` .
647
650
"""
648
651
self .record_once (
649
652
lambda s : s .app .after_request_funcs .setdefault (None , []).append (f )
@@ -652,9 +655,8 @@ def after_app_request(self, f: T_after_request) -> T_after_request:
652
655
653
656
@setupmethod
654
657
def teardown_app_request (self , f : T_teardown ) -> T_teardown :
655
- """Like :meth:`Flask.teardown_request` but for a blueprint. Such a
656
- function is executed when tearing down each request, even if outside of
657
- the blueprint.
658
+ """Like :meth:`teardown_request`, but after every request, not only those
659
+ handled by the blueprint. Equivalent to :meth:`.Flask.teardown_request`.
658
660
"""
659
661
self .record_once (
660
662
lambda s : s .app .teardown_request_funcs .setdefault (None , []).append (f )
@@ -665,8 +667,8 @@ def teardown_app_request(self, f: T_teardown) -> T_teardown:
665
667
def app_context_processor (
666
668
self , f : T_template_context_processor
667
669
) -> T_template_context_processor :
668
- """Like :meth:`Flask. context_processor` but for a blueprint. Such a
669
- function is executed each request, even if outside of the blueprint .
670
+ """Like :meth:`context_processor`, but for templates rendered by every view, not
671
+ only by the blueprint. Equivalent to :meth:`.Flask.context_processor` .
670
672
"""
671
673
self .record_once (
672
674
lambda s : s .app .template_context_processors .setdefault (None , []).append (f )
@@ -677,8 +679,8 @@ def app_context_processor(
677
679
def app_errorhandler (
678
680
self , code : t .Union [t .Type [Exception ], int ]
679
681
) -> t .Callable [[T_error_handler ], T_error_handler ]:
680
- """Like :meth:`Flask. errorhandler` but for a blueprint. This
681
- handler is used for all requests, even if outside of the blueprint .
682
+ """Like :meth:`errorhandler`, but for every request, not only those handled by
683
+ the blueprint. Equivalent to :meth:`.Flask.errorhandler` .
682
684
"""
683
685
684
686
def decorator (f : T_error_handler ) -> T_error_handler :
@@ -691,15 +693,19 @@ def decorator(f: T_error_handler) -> T_error_handler:
691
693
def app_url_value_preprocessor (
692
694
self , f : T_url_value_preprocessor
693
695
) -> T_url_value_preprocessor :
694
- """Same as :meth:`url_value_preprocessor` but application wide."""
696
+ """Like :meth:`url_value_preprocessor`, but for every request, not only those
697
+ handled by the blueprint. Equivalent to :meth:`.Flask.url_value_preprocessor`.
698
+ """
695
699
self .record_once (
696
700
lambda s : s .app .url_value_preprocessors .setdefault (None , []).append (f )
697
701
)
698
702
return f
699
703
700
704
@setupmethod
701
705
def app_url_defaults (self , f : T_url_defaults ) -> T_url_defaults :
702
- """Same as :meth:`url_defaults` but application wide."""
706
+ """Like :meth:`url_defaults`, but for every request, not only those handled by
707
+ the blueprint. Equivalent to :meth:`.Flask.url_defaults`.
708
+ """
703
709
self .record_once (
704
710
lambda s : s .app .url_default_functions .setdefault (None , []).append (f )
705
711
)
0 commit comments