Method: flask.scaffold.Scaffold.__init__
Calls: 538, Exceptions: 0, Paths: 2Back
Path 1: 318 calls (0.59)
'flask_test' (318)
'static' (318)
None (318)
'templates' (318)
'/Users/andrehora/Documents/git/projects-pathspotter/flask/tests' (318)
1def __init__(
2 self,
3 import_name: str,
4 static_folder: str | os.PathLike | None = None,
5 static_url_path: str | None = None,
6 template_folder: str | os.PathLike | None = None,
7 root_path: str | None = None,
8 ):
9 #: The name of the package or module that this object belongs
10 #: to. Do not change this once it is set by the constructor.
11 self.import_name = import_name
12
13 self.static_folder = static_folder # type: ignore
14 self.static_url_path = static_url_path
15
16 #: The path to the templates folder, relative to
17 #: :attr:`root_path`, to add to the template loader. ``None`` if
18 #: templates should not be added.
19 self.template_folder = template_folder
20
21 if root_path is None:
22 root_path = get_root_path(self.import_name)
23
24 #: Absolute path to the package on the filesystem. Used to look
25 #: up resources contained in the package.
26 self.root_path = root_path
27
28 #: The Click command group for registering CLI commands for this
29 #: object. The commands are available from the ``flask`` command
30 #: once the application has been discovered and blueprints have
31 #: been registered.
32 self.cli = AppGroup()
33
34 #: A dictionary mapping endpoint names to view functions.
35 #:
36 #: To register a view function, use the :meth:`route` decorator.
37 #:
38 #: This data structure is internal. It should not be modified
39 #: directly and its format may change at any time.
40 self.view_functions: dict[str, t.Callable] = {}
41
42 #: A data structure of registered error handlers, in the format
43 #: ``{scope: {code: {class: handler}}}``. The ``scope`` key is
44 #: the name of a blueprint the handlers are active for, or
45 #: ``None`` for all requests. The ``code`` key is the HTTP
46 #: status code for ``HTTPException``, or ``None`` for
47 #: other exceptions. The innermost dictionary maps exception
48 #: classes to handler functions.
49 #:
50 #: To register an error handler, use the :meth:`errorhandler`
51 #: decorator.
52 #:
53 #: This data structure is internal. It should not be modified
54 #: directly and its format may change at any time.
55 self.error_handler_spec: dict[
56 ft.AppOrBlueprintKey,
57 dict[int | None, dict[type[Exception], ft.ErrorHandlerCallable]],
58 ] = defaultdict(lambda: defaultdict(dict))
59
60 #: A data structure of functions to call at the beginning of
61 #: each request, in the format ``{scope: [functions]}``. The
62 #: ``scope`` key is the name of a blueprint the functions are
63 #: active for, or ``None`` for all requests.
64 #:
65 #: To register a function, use the :meth:`before_request`
66 #: decorator.
67 #:
68 #: This data structure is internal. It should not be modified
69 #: directly and its format may change at any time.
70 self.before_request_funcs: dict[
71 ft.AppOrBlueprintKey, list[ft.BeforeRequestCallable]
72 ] = defaultdict(list)
73
74 #: A data structure of functions to call at the end of each
75 #: request, in the format ``{scope: [functions]}``. The
76 #: ``scope`` key is the name of a blueprint the functions are
77 #: active for, or ``None`` for all requests.
78 #:
79 #: To register a function, use the :meth:`after_request`
80 #: decorator.
81 #:
82 #: This data structure is internal. It should not be modified
83 #: directly and its format may change at any time.
84 self.after_request_funcs: dict[
85 ft.AppOrBlueprintKey, list[ft.AfterRequestCallable]
86 ] = defaultdict(list)
87
88 #: A data structure of functions to call at the end of each
89 #: request even if an exception is raised, in the format
90 #: ``{scope: [functions]}``. The ``scope`` key is the name of a
91 #: blueprint the functions are active for, or ``None`` for all
92 #: requests.
93 #:
94 #: To register a function, use the :meth:`teardown_request`
95 #: decorator.
96 #:
97 #: This data structure is internal. It should not be modified
98 #: directly and its format may change at any time.
99 self.teardown_request_funcs: dict[
100 ft.AppOrBlueprintKey, list[ft.TeardownCallable]
101 ] = defaultdict(list)
102
103 #: A data structure of functions to call to pass extra context
104 #: values when rendering templates, in the format
105 #: ``{scope: [functions]}``. The ``scope`` key is the name of a
106 #: blueprint the functions are active for, or ``None`` for all
107 #: requests.
108 #:
109 #: To register a function, use the :meth:`context_processor`
110 #: decorator.
111 #:
112 #: This data structure is internal. It should not be modified
113 #: directly and its format may change at any time.
114 self.template_context_processors: dict[
115 ft.AppOrBlueprintKey, list[ft.TemplateContextProcessorCallable]
116 ] = defaultdict(list, {None: [_default_template_ctx_processor]})
117
118 #: A data structure of functions to call to modify the keyword
119 #: arguments passed to the view function, in the format
120 #: ``{scope: [functions]}``. The ``scope`` key is the name of a
121 #: blueprint the functions are active for, or ``None`` for all
122 #: requests.
123 #:
124 #: To register a function, use the
125 #: :meth:`url_value_preprocessor` decorator.
126 #:
127 #: This data structure is internal. It should not be modified
128 #: directly and its format may change at any time.
129 self.url_value_preprocessors: dict[
130 ft.AppOrBlueprintKey,
131 list[ft.URLValuePreprocessorCallable],
132 ] = defaultdict(list)
133
134 #: A data structure of functions to call to modify the keyword
135 #: arguments when generating URLs, in the format
136 #: ``{scope: [functions]}``. The ``scope`` key is the name of a
137 #: blueprint the functions are active for, or ``None`` for all
138 #: requests.
139 #:
140 #: To register a function, use the :meth:`url_defaults`
141 #: decorator.
142 #:
143 #: This data structure is internal. It should not be modified
144 #: directly and its format may change at any time.
145 self.url_default_functions: dict[
146 ft.AppOrBlueprintKey, list[ft.URLDefaultCallable]
147 ] = defaultdict(list)
Path 2: 220 calls (0.41)
'test_blueprints' (73) 'test_config' (22) 'test_basic' (21) 'test_async' (16) 'test_cli' (11) 'test_helpers' (10) 'test_templating' (7) 'testapp' (6) ...
'static' (124) None (92) '' (2) PosixPath (1) 'static/' (1)
None (217) '/foo' (1) '/foo/' (1) '' (1)
'templates' (131) None (88) 'template' (1)
None (220)
1def __init__(
2 self,
3 import_name: str,
4 static_folder: str | os.PathLike | None = None,
5 static_url_path: str | None = None,
6 template_folder: str | os.PathLike | None = None,
7 root_path: str | None = None,
8 ):
9 #: The name of the package or module that this object belongs
10 #: to. Do not change this once it is set by the constructor.
11 self.import_name = import_name
12
13 self.static_folder = static_folder # type: ignore
14 self.static_url_path = static_url_path
15
16 #: The path to the templates folder, relative to
17 #: :attr:`root_path`, to add to the template loader. ``None`` if
18 #: templates should not be added.
19 self.template_folder = template_folder
20
21 if root_path is None:
22 root_path = get_root_path(self.import_name)
23
24 #: Absolute path to the package on the filesystem. Used to look
25 #: up resources contained in the package.
26 self.root_path = root_path
27
28 #: The Click command group for registering CLI commands for this
29 #: object. The commands are available from the ``flask`` command
30 #: once the application has been discovered and blueprints have
31 #: been registered.
32 self.cli = AppGroup()
33
34 #: A dictionary mapping endpoint names to view functions.
35 #:
36 #: To register a view function, use the :meth:`route` decorator.
37 #:
38 #: This data structure is internal. It should not be modified
39 #: directly and its format may change at any time.
40 self.view_functions: dict[str, t.Callable] = {}
41
42 #: A data structure of registered error handlers, in the format
43 #: ``{scope: {code: {class: handler}}}``. The ``scope`` key is
44 #: the name of a blueprint the handlers are active for, or
45 #: ``None`` for all requests. The ``code`` key is the HTTP
46 #: status code for ``HTTPException``, or ``None`` for
47 #: other exceptions. The innermost dictionary maps exception
48 #: classes to handler functions.
49 #:
50 #: To register an error handler, use the :meth:`errorhandler`
51 #: decorator.
52 #:
53 #: This data structure is internal. It should not be modified
54 #: directly and its format may change at any time.
55 self.error_handler_spec: dict[
56 ft.AppOrBlueprintKey,
57 dict[int | None, dict[type[Exception], ft.ErrorHandlerCallable]],
58 ] = defaultdict(lambda: defaultdict(dict))
59
60 #: A data structure of functions to call at the beginning of
61 #: each request, in the format ``{scope: [functions]}``. The
62 #: ``scope`` key is the name of a blueprint the functions are
63 #: active for, or ``None`` for all requests.
64 #:
65 #: To register a function, use the :meth:`before_request`
66 #: decorator.
67 #:
68 #: This data structure is internal. It should not be modified
69 #: directly and its format may change at any time.
70 self.before_request_funcs: dict[
71 ft.AppOrBlueprintKey, list[ft.BeforeRequestCallable]
72 ] = defaultdict(list)
73
74 #: A data structure of functions to call at the end of each
75 #: request, in the format ``{scope: [functions]}``. The
76 #: ``scope`` key is the name of a blueprint the functions are
77 #: active for, or ``None`` for all requests.
78 #:
79 #: To register a function, use the :meth:`after_request`
80 #: decorator.
81 #:
82 #: This data structure is internal. It should not be modified
83 #: directly and its format may change at any time.
84 self.after_request_funcs: dict[
85 ft.AppOrBlueprintKey, list[ft.AfterRequestCallable]
86 ] = defaultdict(list)
87
88 #: A data structure of functions to call at the end of each
89 #: request even if an exception is raised, in the format
90 #: ``{scope: [functions]}``. The ``scope`` key is the name of a
91 #: blueprint the functions are active for, or ``None`` for all
92 #: requests.
93 #:
94 #: To register a function, use the :meth:`teardown_request`
95 #: decorator.
96 #:
97 #: This data structure is internal. It should not be modified
98 #: directly and its format may change at any time.
99 self.teardown_request_funcs: dict[
100 ft.AppOrBlueprintKey, list[ft.TeardownCallable]
101 ] = defaultdict(list)
102
103 #: A data structure of functions to call to pass extra context
104 #: values when rendering templates, in the format
105 #: ``{scope: [functions]}``. The ``scope`` key is the name of a
106 #: blueprint the functions are active for, or ``None`` for all
107 #: requests.
108 #:
109 #: To register a function, use the :meth:`context_processor`
110 #: decorator.
111 #:
112 #: This data structure is internal. It should not be modified
113 #: directly and its format may change at any time.
114 self.template_context_processors: dict[
115 ft.AppOrBlueprintKey, list[ft.TemplateContextProcessorCallable]
116 ] = defaultdict(list, {None: [_default_template_ctx_processor]})
117
118 #: A data structure of functions to call to modify the keyword
119 #: arguments passed to the view function, in the format
120 #: ``{scope: [functions]}``. The ``scope`` key is the name of a
121 #: blueprint the functions are active for, or ``None`` for all
122 #: requests.
123 #:
124 #: To register a function, use the
125 #: :meth:`url_value_preprocessor` decorator.
126 #:
127 #: This data structure is internal. It should not be modified
128 #: directly and its format may change at any time.
129 self.url_value_preprocessors: dict[
130 ft.AppOrBlueprintKey,
131 list[ft.URLValuePreprocessorCallable],
132 ] = defaultdict(list)
133
134 #: A data structure of functions to call to modify the keyword
135 #: arguments when generating URLs, in the format
136 #: ``{scope: [functions]}``. The ``scope`` key is the name of a
137 #: blueprint the functions are active for, or ``None`` for all
138 #: requests.
139 #:
140 #: To register a function, use the :meth:`url_defaults`
141 #: decorator.
142 #:
143 #: This data structure is internal. It should not be modified
144 #: directly and its format may change at any time.
145 self.url_default_functions: dict[
146 ft.AppOrBlueprintKey, list[ft.URLDefaultCallable]
147 ] = defaultdict(list)