Method: flask.helpers.get_flashed_messages
Calls: 5, Exceptions: 0, Paths: 4Back
Path 1: 2 calls (0.4)
True (2)
['message'] (1) ['message', 'warning'] (1)
list (2)
1def get_flashed_messages(
2 with_categories: bool = False, category_filter: t.Iterable[str] = ()
3) -> list[str] | list[tuple[str, str]]:
4 """Pulls all flashed messages from the session and returns them.
5 Further calls in the same request to the function will return
6 the same messages. By default just the messages are returned,
7 but when `with_categories` is set to ``True``, the return value will
8 be a list of tuples in the form ``(category, message)`` instead.
9
10 Filter the flashed messages to one or more categories by providing those
11 categories in `category_filter`. This allows rendering categories in
12 separate html blocks. The `with_categories` and `category_filter`
13 arguments are distinct:
14
15 * `with_categories` controls whether categories are returned with message
16 text (``True`` gives a tuple, where ``False`` gives just the message text).
17 * `category_filter` filters the messages down to only those matching the
18 provided categories.
19
20 See :doc:`/patterns/flashing` for examples.
21
22 .. versionchanged:: 0.3
23 `with_categories` parameter added.
24
25 .. versionchanged:: 0.9
26 `category_filter` parameter added.
27
28 :param with_categories: set to ``True`` to also receive categories.
29 :param category_filter: filter of categories to limit return values. Only
30 categories in the list will be returned.
31 """
32 flashes = request_ctx.flashes
33 if flashes is None:
34 flashes = session.pop("_flashes") if "_flashes" in session else []
35 request_ctx.flashes = flashes
36 if category_filter:
37 flashes = list(filter(lambda f: f[0] in category_filter, flashes))
38 if not with_categories:
39 return [x[1] for x in flashes]
40 return flashes
Path 2: 1 calls (0.2)
False (1)
() (1)
['Zap', 'Zip'] (1)
1def get_flashed_messages(
2 with_categories: bool = False, category_filter: t.Iterable[str] = ()
3) -> list[str] | list[tuple[str, str]]:
4 """Pulls all flashed messages from the session and returns them.
5 Further calls in the same request to the function will return
6 the same messages. By default just the messages are returned,
7 but when `with_categories` is set to ``True``, the return value will
8 be a list of tuples in the form ``(category, message)`` instead.
9
10 Filter the flashed messages to one or more categories by providing those
11 categories in `category_filter`. This allows rendering categories in
12 separate html blocks. The `with_categories` and `category_filter`
13 arguments are distinct:
14
15 * `with_categories` controls whether categories are returned with message
16 text (``True`` gives a tuple, where ``False`` gives just the message text).
17 * `category_filter` filters the messages down to only those matching the
18 provided categories.
19
20 See :doc:`/patterns/flashing` for examples.
21
22 .. versionchanged:: 0.3
23 `with_categories` parameter added.
24
25 .. versionchanged:: 0.9
26 `category_filter` parameter added.
27
28 :param with_categories: set to ``True`` to also receive categories.
29 :param category_filter: filter of categories to limit return values. Only
30 categories in the list will be returned.
31 """
32 flashes = request_ctx.flashes
33 if flashes is None:
34 flashes = session.pop("_flashes") if "_flashes" in session else []
35 request_ctx.flashes = flashes
36 if category_filter:
37 flashes = list(filter(lambda f: f[0] in category_filter, flashes))
38 if not with_categories:
39 return [x[1] for x in flashes]
40 return flashes
Path 3: 1 calls (0.2)
True (1)
() (1)
list (1)
1def get_flashed_messages(
2 with_categories: bool = False, category_filter: t.Iterable[str] = ()
3) -> list[str] | list[tuple[str, str]]:
4 """Pulls all flashed messages from the session and returns them.
5 Further calls in the same request to the function will return
6 the same messages. By default just the messages are returned,
7 but when `with_categories` is set to ``True``, the return value will
8 be a list of tuples in the form ``(category, message)`` instead.
9
10 Filter the flashed messages to one or more categories by providing those
11 categories in `category_filter`. This allows rendering categories in
12 separate html blocks. The `with_categories` and `category_filter`
13 arguments are distinct:
14
15 * `with_categories` controls whether categories are returned with message
16 text (``True`` gives a tuple, where ``False`` gives just the message text).
17 * `category_filter` filters the messages down to only those matching the
18 provided categories.
19
20 See :doc:`/patterns/flashing` for examples.
21
22 .. versionchanged:: 0.3
23 `with_categories` parameter added.
24
25 .. versionchanged:: 0.9
26 `category_filter` parameter added.
27
28 :param with_categories: set to ``True`` to also receive categories.
29 :param category_filter: filter of categories to limit return values. Only
30 categories in the list will be returned.
31 """
32 flashes = request_ctx.flashes
33 if flashes is None:
34 flashes = session.pop("_flashes") if "_flashes" in session else []
35 request_ctx.flashes = flashes
36 if category_filter:
37 flashes = list(filter(lambda f: f[0] in category_filter, flashes))
38 if not with_categories:
39 return [x[1] for x in flashes]
40 return flashes
Path 4: 1 calls (0.2)
False (1)
['message', 'warning'] (1)
list (1)
1def get_flashed_messages(
2 with_categories: bool = False, category_filter: t.Iterable[str] = ()
3) -> list[str] | list[tuple[str, str]]:
4 """Pulls all flashed messages from the session and returns them.
5 Further calls in the same request to the function will return
6 the same messages. By default just the messages are returned,
7 but when `with_categories` is set to ``True``, the return value will
8 be a list of tuples in the form ``(category, message)`` instead.
9
10 Filter the flashed messages to one or more categories by providing those
11 categories in `category_filter`. This allows rendering categories in
12 separate html blocks. The `with_categories` and `category_filter`
13 arguments are distinct:
14
15 * `with_categories` controls whether categories are returned with message
16 text (``True`` gives a tuple, where ``False`` gives just the message text).
17 * `category_filter` filters the messages down to only those matching the
18 provided categories.
19
20 See :doc:`/patterns/flashing` for examples.
21
22 .. versionchanged:: 0.3
23 `with_categories` parameter added.
24
25 .. versionchanged:: 0.9
26 `category_filter` parameter added.
27
28 :param with_categories: set to ``True`` to also receive categories.
29 :param category_filter: filter of categories to limit return values. Only
30 categories in the list will be returned.
31 """
32 flashes = request_ctx.flashes
33 if flashes is None:
34 flashes = session.pop("_flashes") if "_flashes" in session else []
35 request_ctx.flashes = flashes
36 if category_filter:
37 flashes = list(filter(lambda f: f[0] in category_filter, flashes))
38 if not with_categories:
39 return [x[1] for x in flashes]
40 return flashes