Skip to content
Myr

Merge branch '3.0.x'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parents a855756, 6118224 · Browse files · 8 files+75 added−15 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

8 files+75 added−15 removed

  • other:+75 added−15 removed

8 files+75 added−15 removed

modified:docs/logging.rst+1 added-1 removed
157 unmodified lines
158Depending on your project, it may be more useful to configure each logger you159care about separately, instead of configuring only the root logger. ::160161 for logger in (162 app.logger,162 logging.getLogger(app.name),163 logging.getLogger('sqlalchemy'),164 logging.getLogger('other_package'),165 ):166 logger.addHandler(default_handler)
17 unmodified lines
modified:src/flask/sansio/app.py-4 removed
408 unmodified lines
409 # tracks internally if the application already handled at least one410 # request.411 self._got_first_request = False412413 # Set the name of the Click group in case someone wants to add414 # the app's commands to another CLI tool.415 self.cli.name = self.name416413 def _check_setup_finished(self, f_name: str) -> None:414 if self._got_first_request:415 raise AssertionError(416 f"The setup method '{f_name}' can no longer be called"
548 unmodified lines
modified:src/flask/sansio/scaffold.py+4 added-8 removed
6 unmodified lines
7import typing as t8from collections import defaultdict9from functools import update_wrapper1011import click11from jinja2 import BaseLoader12from jinja2 import FileSystemLoader13from werkzeug.exceptions import default_exceptions14from werkzeug.exceptions import HTTPException15from werkzeug.utils import cached_property1617from .. import typing as ft19from ..cli import AppGroup18from ..helpers import get_root_path19from ..templating import _default_template_ctx_processor2021if t.TYPE_CHECKING: # pragma: no cover22 from click import Group2324# a singleton sentinel value for parameter defaults25_sentinel = object()2627F = t.TypeVar("F", bound=t.Callable[..., t.Any])
38 unmodified lines
6667 .. versionadded:: 2.068 """6970 cli: Group71 name: str72 _static_folder: str | None = None73 _static_url_path: str | None = None74
23 unmodified lines
98 #: Absolute path to the package on the filesystem. Used to look99 #: up resources contained in the package.100 self.root_path = root_path101100 #: The Click command group for registering CLI commands for this101 #: object. The commands are available from the ``flask`` command102 #: once the application has been discovered and blueprints have103 #: been registered.104 self.cli: click.Group = AppGroup()105102 #: A dictionary mapping endpoint names to view functions.103 #:104 #: To register a view function, use the :meth:`route` decorator.105 #:
696 unmodified lines
modified:src/flask/app.py+10 added
239 unmodified lines
240 instance_relative_config=instance_relative_config,241 root_path=root_path,242 )243244 #: The Click command group for registering CLI commands for this245 #: object. The commands are available from the ``flask`` command246 #: once the application has been discovered and blueprints have247 #: been registered.248 self.cli = cli.AppGroup()249250 # Set the name of the Click group in case someone wants to add251 # the app's commands to another CLI tool.252 self.cli.name = self.name253254 # Add a static route using the provided static_url_path, static_host,255 # and static_folder if there is a configured static_folder.256 # Note we do this without checking if static_folder exists.257 # For one, it might be created while the server is running (e.g. during
1241 unmodified lines
modified:src/flask/blueprints.py+38 added
2 unmodified lines
3import os4import typing as t5from datetime import timedelta67from .cli import AppGroup8from .globals import current_app9from .helpers import send_from_directory10from .sansio.blueprints import Blueprint as SansioBlueprint11from .sansio.blueprints import BlueprintSetupState as BlueprintSetupState # noqa12from .sansio.scaffold import _sentinel1314if t.TYPE_CHECKING: # pragma: no cover15 from .wrappers import Response161718class Blueprint(SansioBlueprint):19 def __init__(20 self,21 name: str,22 import_name: str,23 static_folder: str | os.PathLike[str] | None = None,24 static_url_path: str | None = None,25 template_folder: str | os.PathLike[str] | None = None,26 url_prefix: str | None = None,27 subdomain: str | None = None,28 url_defaults: dict[str, t.Any] | None = None,29 root_path: str | None = None,30 cli_group: str | None = _sentinel, # type: ignore31 ) -> None:32 super().__init__(33 name,34 import_name,35 static_folder,36 static_url_path,37 template_folder,38 url_prefix,39 subdomain,40 url_defaults,41 root_path,42 cli_group,43 )4445 #: The Click command group for registering CLI commands for this46 #: object. The commands are available from the ``flask`` command47 #: once the application has been discovered and blueprints have48 #: been registered.49 self.cli = AppGroup()5051 # Set the name of the Click group in case someone wants to add52 # the app's commands to another CLI tool.53 self.cli.name = self.name5455 def get_send_file_max_age(self, filename: str | None) -> int | None:56 """Used by :func:`send_file` to determine the ``max_age`` cache57 value for a given file path if it wasn't passed.58
71 unmodified lines
modified:src/flask/sessions.py+9 added-1 removed
275 unmodified lines
276277session_json_serializer = TaggedJSONSerializer()278279280def _lazy_sha1(string: bytes = b"") -> t.Any:281 """Don't access ``hashlib.sha1`` until runtime. FIPS builds may not include282 SHA-1, in which case the import and use as a default would fail before the283 developer can configure something else.284 """285 return hashlib.sha1(string)286287288class SecureCookieSessionInterface(SessionInterface):289 """The default session interface that stores sessions in signed cookies290 through the :mod:`itsdangerous` module.291 """
1 unmodified line
293 #: the salt that should be applied on top of the secret key for the294 #: signing of cookie based sessions.295 salt = "cookie-session"296 #: the hash function to use for the signature. The default is sha1289 digest_method = staticmethod(hashlib.sha1)297 digest_method = staticmethod(_lazy_sha1)298 #: the name of the itsdangerous supported key derivation. The default299 #: is hmac.300 key_derivation = "hmac"301 #: A python serializer for the payload. The default is a compact
78 unmodified lines
modified:CHANGES.rst+12 added
1Version 3.0.32-------------34Released 2024-04-0756- The default ``hashlib.sha1`` may not be available in FIPS builds. Don't7 access it at import time so the developer has time to change the default.8 :issue:`5448`9- Don't initialize the ``cli`` attribute in the sansio scaffold, but rather in10 the ``Flask`` concrete class. :pr:`5270`111213Version 3.0.214-------------1516Released 2024-02-03
1549 unmodified lines
modified:pyproject.toml+1 added-1 removed