Merge branch '2.2.x'

This commit is contained in:
David Lord 2022-08-27 06:04:55 -07:00
commit 73b9bacbf7
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
11 changed files with 25 additions and 15 deletions

View file

@ -4,6 +4,12 @@ Version 2.3.0
Unreleased Unreleased
Version 2.2.3
-------------
Unreleased
Version 2.2.2 Version 2.2.2
------------- -------------

View file

@ -66,7 +66,6 @@ interface. The links below are for some of the most common platforms,
which have instructions for Flask, WSGI, or Python. which have instructions for Flask, WSGI, or Python.
- `PythonAnywhere <https://help.pythonanywhere.com/pages/Flask/>`_ - `PythonAnywhere <https://help.pythonanywhere.com/pages/Flask/>`_
- `Heroku <https://devcenter.heroku.com/articles/getting-started-with-python>`_
- `Google App Engine <https://cloud.google.com/appengine/docs/standard/python3/building-app>`_ - `Google App Engine <https://cloud.google.com/appengine/docs/standard/python3/building-app>`_
- `Google Cloud Run <https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-python-service>`_ - `Google Cloud Run <https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-python-service>`_
- `AWS Elastic Beanstalk <https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-flask.html>`_ - `AWS Elastic Beanstalk <https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-flask.html>`_

View file

@ -45,10 +45,10 @@ pattern, use ``--call {module}:{factory}`` instead.
.. code-block:: text .. code-block:: text
# equivalent to 'from hello import app' # equivalent to 'from hello import app'
$ waitress-serve hello:app --host 127.0.0.1 $ waitress-serve --host 127.0.0.1 hello:app
# equivalent to 'from hello import create_app; create_app()' # equivalent to 'from hello import create_app; create_app()'
$ waitress-serve --call hello:create_app --host 127.0.0.1 $ waitress-serve --host 127.0.0.1 --call hello:create_app
Serving on http://127.0.0.1:8080 Serving on http://127.0.0.1:8080

View file

@ -184,7 +184,7 @@ context is active when a request context is, or when a CLI command is
run. If you're storing something that should be closed, use run. If you're storing something that should be closed, use
:meth:`~flask.Flask.teardown_appcontext` to ensure that it gets closed :meth:`~flask.Flask.teardown_appcontext` to ensure that it gets closed
when the application context ends. If it should only be valid during a when the application context ends. If it should only be valid during a
request, or would not be used in the CLI outside a reqeust, use request, or would not be used in the CLI outside a request, use
:meth:`~flask.Flask.teardown_request`. :meth:`~flask.Flask.teardown_request`.

View file

@ -28,7 +28,7 @@ It is important to understand the difference between templates and
JavaScript. Templates are rendered on the server, before the response is JavaScript. Templates are rendered on the server, before the response is
sent to the user's browser. JavaScript runs in the user's browser, after sent to the user's browser. JavaScript runs in the user's browser, after
the template is rendered and sent. Therefore, it is impossible to use the template is rendered and sent. Therefore, it is impossible to use
JavaScript to affect how the Jinja template is rendered, but is is JavaScript to affect how the Jinja template is rendered, but it is
possible to render data into the JavaScript that will run. possible to render data into the JavaScript that will run.
To provide data to JavaScript when rendering the template, use the To provide data to JavaScript when rendering the template, use the

View file

@ -20,7 +20,7 @@ data and to then invoke that function and pass it to a response object::
def generate(): def generate():
for row in iter_all_rows(): for row in iter_all_rows():
yield f"{','.join(row)}\n" yield f"{','.join(row)}\n"
return generate(), {"Content-Type": "text/csv") return generate(), {"Content-Type": "text/csv"}
Each ``yield`` expression is directly sent to the browser. Note though Each ``yield`` expression is directly sent to the browser. Note though
that some WSGI middlewares might break streaming, so be careful there in that some WSGI middlewares might break streaming, so be careful there in

View file

@ -41,7 +41,7 @@ itself.
To run the application, use the ``flask`` command or To run the application, use the ``flask`` command or
``python -m flask``. You need to tell the Flask where your application ``python -m flask``. You need to tell the Flask where your application
is with the ``-app`` option. is with the ``--app`` option.
.. code-block:: text .. code-block:: text

View file

@ -41,7 +41,6 @@ to it.
version='1.0.0', version='1.0.0',
packages=find_packages(), packages=find_packages(),
include_package_data=True, include_package_data=True,
zip_safe=False,
install_requires=[ install_requires=[
'flask', 'flask',
], ],

View file

@ -116,7 +116,10 @@ function.
item = self.model.query.get_or_404(id) item = self.model.query.get_or_404(id)
return render_template(self.template, item=item) return render_template(self.template, item=item)
app.add_url_rule("/users/<int:id>", view_func=DetailView.as_view("user_detail")) app.add_url_rule(
"/users/<int:id>",
view_func=DetailView.as_view("user_detail", User)
)
View Lifetime and ``self`` View Lifetime and ``self``
@ -295,8 +298,10 @@ provide get (list) and post (create) methods.
return jsonify(item.to_json()) return jsonify(item.to_json())
def register_api(app, model, url): def register_api(app, model, url):
app.add_url_rule(f"/{name}/<int:id>", view_func=ItemAPI(f"{name}-item", model)) item = ItemAPI.as_view(f"{name}-item", model)
app.add_url_rule(f"/{name}/", view_func=GroupAPI(f"{name}-group", model)) group = GroupAPI.as_view(f"{name}-group", model)
app.add_url_rule(f"/{name}/<int:id>", view_func=item)
app.add_url_rule(f"/{name}/", view_func=group)
register_api(app, User, "users") register_api(app, User, "users")
register_api(app, Story, "stories") register_api(app, Story, "stories")

View file

@ -275,8 +275,9 @@ class Config(dict):
def from_mapping( def from_mapping(
self, mapping: t.Optional[t.Mapping[str, t.Any]] = None, **kwargs: t.Any self, mapping: t.Optional[t.Mapping[str, t.Any]] = None, **kwargs: t.Any
) -> bool: ) -> bool:
"""Updates the config like :meth:`update` ignoring items with non-upper """Updates the config like :meth:`update` ignoring items with
keys. non-upper keys.
:return: Always returns ``True``. :return: Always returns ``True``.
.. versionadded:: 0.11 .. versionadded:: 0.11

View file

@ -88,7 +88,7 @@ def __getattr__(name: str) -> t.Any:
import warnings import warnings
warnings.warn( warnings.warn(
"'_app_ctx_stack' is deprecated and will be remoevd in Flask 2.3.", "'_app_ctx_stack' is deprecated and will be removed in Flask 2.3.",
DeprecationWarning, DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
@ -98,7 +98,7 @@ def __getattr__(name: str) -> t.Any:
import warnings import warnings
warnings.warn( warnings.warn(
"'_request_ctx_stack' is deprecated and will be remoevd in Flask 2.3.", "'_request_ctx_stack' is deprecated and will be removed in Flask 2.3.",
DeprecationWarning, DeprecationWarning,
stacklevel=2, stacklevel=2,
) )