Merge remote-tracking branch 'origin/stable'
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 2eab96a, 6c44dd4 · Browse files · 11 files·+79 added−62 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
11 files+79 added−62 removed
- tests:+1 added−1 removed
- other:+78 added−61 removed
Provenance
- Commit
22c48a7- Tree
dfa780c- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent 1
2eab96a- Parent 2
6c44dd4
11 files changed+79 added−62 removed
modified:docs/tutorial/database.rst+10 added
35 unmodified lines36 .. code-block:: python37 :caption: ``flaskr/db.py``38 39 import sqlite340+ from datetime import datetime41 42 import click43 from flask import current_app, g44 87 unmodified lines132 """Clear the existing data and create new tables."""133 init_db()134 click.echo('Initialized the database.')135 136+137+ sqlite3.register_converter(138+ "timestamp", lambda v: datetime.fromisoformat(v.decode())139+ )140+141 :meth:`open_resource() <Flask.open_resource>` opens a file relative to142 the ``flaskr`` package, which is useful since you won't necessarily know143 where that location is when deploying the application later. ``get_db``144 returns a database connection, which is used to execute the commands2 unmodified lines147 :func:`click.command` defines a command line command called ``init-db``148 that calls the ``init_db`` function and shows a success message to the149 user. You can read :doc:`/cli` to learn more about writing commands.150 151+The call to :func:`sqlite3.register_converter` tells Python how to152+interpret timestamp values in the database. We convert the value to a153+:class:`datetime.datetime`.154 155+156 Register with the Application157 -----------------------------158 159 The ``close_db`` and ``init_db_command`` functions need to be registered60 unmodified linesmodified:examples/celery/pyproject.toml+2 added-2 removed
1234567678910116 unmodified lines[project]name = "flask-example-celery"version = "1.0.0"description = "Example Flask application with Celery background tasks."readme = "README.md"requires-python = ">=3.8"dependencies = ["flask>=2.2.2", "celery[redis]>=5.2.7"]classifiers = ["Private :: Do Not Upload"]dependencies = ["flask", "celery[redis]"]
[build-system]requires = ["flit_core<4"]build-backend = "flit_core.buildapi"6 unmodified linesmodified:examples/javascript/tests/test_js_example.py+1 added-1 removed
3 unmodified lines4 5 @pytest.mark.parametrize(6 ("path", "template_name"),7 (8- ("/", "xhr.html"),8+ ("/", "fetch.html"),9 ("/plain", "xhr.html"),10 ("/fetch", "fetch.html"),11 ("/jquery", "jquery.html"),12 ),15 unmodified linesdeleted:examples/javascript/LICENSE.rst-28 removed
1-Copyright 2010 Pallets2-3-Redistribution and use in source and binary forms, with or without4-modification, are permitted provided that the following conditions are5-met:6-7-1. Redistributions of source code must retain the above copyright8- notice, this list of conditions and the following disclaimer.9-10-2. Redistributions in binary form must reproduce the above copyright11- notice, this list of conditions and the following disclaimer in the12- documentation and/or other materials provided with the distribution.13-14-3. Neither the name of the copyright holder nor the names of its15- contributors may be used to endorse or promote products derived from16- this software without specific prior written permission.17-18-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS19-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT20-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A21-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT22-HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,23-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED24-TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR25-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF26-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING27-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS28-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.added:examples/javascript/LICENSE.txt+28 added
1+Copyright 2010 Pallets2+3+Redistribution and use in source and binary forms, with or without4+modification, are permitted provided that the following conditions are5+met:6+7+1. Redistributions of source code must retain the above copyright8+ notice, this list of conditions and the following disclaimer.9+10+2. Redistributions in binary form must reproduce the above copyright11+ notice, this list of conditions and the following disclaimer in the12+ documentation and/or other materials provided with the distribution.13+14+3. Neither the name of the copyright holder nor the names of its15+ contributors may be used to endorse or promote products derived from16+ this software without specific prior written permission.17+18+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS19+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT20+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A21+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT22+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,23+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED24+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR25+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF26+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING27+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS28+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.modified:examples/javascript/pyproject.toml+2 added-1 removed
123456678910111221 unmodified lines[project]name = "js_example"version = "1.1.0"description = "Demonstrates making AJAX requests to Flask."readme = "README.rst"license = {file = "LICENSE.rst"}license = {file = "LICENSE.txt"}maintainers = [{name = "Pallets", email = "contact@palletsprojects.com"}]classifiers = ["Private :: Do Not Upload"]dependencies = ["flask"]
[project.urls]Documentation = "https://flask.palletsprojects.com/patterns/javascript/"21 unmodified linesmodified:examples/tutorial/flaskr/db.py+4 added
1 import sqlite32+from datetime import datetime3 4 import click5 from flask import current_app6 from flask import g37 unmodified lines44 init_db()45 click.echo("Initialized the database.")46 47 48+sqlite3.register_converter("timestamp", lambda v: datetime.fromisoformat(v.decode()))49+50+51 def init_app(app):52 """Register database functions with the Flask app. This is called by53 the application factory.54 """2 unmodified linesdeleted:examples/tutorial/LICENSE.rst-28 removed
1-Copyright 2010 Pallets2-3-Redistribution and use in source and binary forms, with or without4-modification, are permitted provided that the following conditions are5-met:6-7-1. Redistributions of source code must retain the above copyright8- notice, this list of conditions and the following disclaimer.9-10-2. Redistributions in binary form must reproduce the above copyright11- notice, this list of conditions and the following disclaimer in the12- documentation and/or other materials provided with the distribution.13-14-3. Neither the name of the copyright holder nor the names of its15- contributors may be used to endorse or promote products derived from16- this software without specific prior written permission.17-18-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS19-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT20-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A21-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT22-HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,23-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED24-TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR25-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF26-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING27-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS28-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.added:examples/tutorial/LICENSE.txt+28 added
1+Copyright 2010 Pallets2+3+Redistribution and use in source and binary forms, with or without4+modification, are permitted provided that the following conditions are5+met:6+7+1. Redistributions of source code must retain the above copyright8+ notice, this list of conditions and the following disclaimer.9+10+2. Redistributions in binary form must reproduce the above copyright11+ notice, this list of conditions and the following disclaimer in the12+ documentation and/or other materials provided with the distribution.13+14+3. Neither the name of the copyright holder nor the names of its15+ contributors may be used to endorse or promote products derived from16+ this software without specific prior written permission.17+18+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS19+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT20+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A21+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT22+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,23+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED24+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR25+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF26+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING27+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS28+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.modified:examples/tutorial/pyproject.toml+2 added-1 removed
1 unmodified line2 name = "flaskr"3 version = "1.0.0"4 description = "The basic blog app built in the Flask tutorial."5 readme = "README.rst"6-license = {text = "BSD-3-Clause"}6+license = {file = "LICENSE.txt"}7 maintainers = [{name = "Pallets", email = "contact@palletsprojects.com"}]8+classifiers = ["Private :: Do Not Upload"]9 dependencies = [10 "flask",11 ]12 28 unmodified linesmodified:src/flask/helpers.py+2 added-1 removed
545 unmodified lines546 If the final path does not point to an existing regular file,547 raises a 404 :exc:`~werkzeug.exceptions.NotFound` error.548 549 :param directory: The directory that ``path`` must be located under,550- relative to the current application's root path.550+ relative to the current application's root path. This *must not*551+ be a value provided by the client, otherwise it becomes insecure.552 :param path: The path to the file to send, relative to553 ``directory``.554 :param kwargs: Arguments to pass to :func:`send_file`.555 79 unmodified lines