diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..90f94bc32 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + day: "monday" + time: "16:00" + timezone: "UTC" diff --git a/.github/workflows/lock.yaml b/.github/workflows/lock.yaml new file mode 100644 index 000000000..b4f763387 --- /dev/null +++ b/.github/workflows/lock.yaml @@ -0,0 +1,15 @@ +name: 'Lock threads' + +on: + schedule: + - cron: '0 0 * * *' + +jobs: + lock: + runs-on: ubuntu-latest + steps: + - uses: dessant/lock-threads@v3 + with: + github-token: ${{ github.token }} + issue-inactive-days: 14 + pr-inactive-days: 14 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d03efe776..0374fc97f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -13,6 +13,7 @@ on: paths-ignore: - '*.md' jobs: +<<<<<<< HEAD docs: name: docs runs-on: ubuntu-latest @@ -20,5 +21,38 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 - run: python -m pip install --upgrade pip wheel +======= + tests: + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - {name: Linux, python: '3.10', os: ubuntu-latest, tox: py310} + - {name: Windows, python: '3.10', os: windows-latest, tox: py310} + - {name: Mac, python: '3.10', os: macos-latest, tox: py310} + - {name: '3.11-dev', python: '3.11-dev', os: ubuntu-latest, tox: py311} + - {name: '3.9', python: '3.9', os: ubuntu-latest, tox: py39} + - {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38} + - {name: '3.7', python: '3.7', os: ubuntu-latest, tox: py37} + - {name: '3.6', python: '3.6', os: ubuntu-latest, tox: py36} + - {name: 'PyPy', python: 'pypy-3.7', os: ubuntu-latest, tox: pypy37} + - {name: 'Pallets Minimum Versions', python: '3.10', os: ubuntu-latest, tox: py-min} + - {name: 'Pallets Development Versions', python: '3.7', os: ubuntu-latest, tox: py-dev} + - {name: Typing, python: '3.10', os: ubuntu-latest, tox: typing} + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + cache: 'pip' + cache-dependency-path: 'requirements/*.txt' + - name: update pip + run: | + pip install -U wheel + pip install -U setuptools + python -m pip install -U pip +>>>>>>> flask/2.0.x - run: pip install tox - run: tox -e docs diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d75f3c310..6b2c6685d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,31 +1,37 @@ ci: + autoupdate_branch: "2.0.x" autoupdate_schedule: monthly repos: - repo: https://github.com/asottile/pyupgrade - rev: v2.15.0 + rev: v2.31.0 hooks: - id: pyupgrade args: ["--py36-plus"] - repo: https://github.com/asottile/reorder_python_imports - rev: v2.5.0 + rev: v2.7.1 hooks: - id: reorder-python-imports name: Reorder Python imports (src, tests) files: "^(?!examples/)" args: ["--application-directories", "src"] + additional_dependencies: ["setuptools>60.9"] - repo: https://github.com/psf/black - rev: 21.5b1 + rev: 22.1.0 hooks: - id: black - repo: https://github.com/PyCQA/flake8 - rev: 3.9.2 + rev: 4.0.1 hooks: - id: flake8 additional_dependencies: - flake8-bugbear - flake8-implicit-str-concat + - repo: https://github.com/peterdemin/pip-compile-multi + rev: v2.4.3 + hooks: + - id: pip-compile-multi-verify - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 + rev: v4.1.0 hooks: - id: fix-byte-order-marker - id: trailing-whitespace diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 0c363636f..346900b20 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,4 +1,8 @@ version: 2 +build: + os: ubuntu-20.04 + tools: + python: "3.10" python: install: - requirements: requirements/docs.txt diff --git a/CHANGES.rst b/CHANGES.rst index f4e0b5d06..2f32a5515 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,23 +1,48 @@ .. currentmodule:: flask -Version 2.1.0 +Version 2.0.3 ------------- -Unreleased +Released 2022-02-14 -- Update Click dependency to >= 8.0. +- The test client's ``as_tuple`` parameter is deprecated and will be + removed in Werkzeug 2.1. It is now also deprecated in Flask, to be + removed in Flask 2.1, while remaining compatible with both in + 2.0.x. Use ``response.request.environ`` instead. :pr:`4341` +- Fix type annotation for ``errorhandler`` decorator. :issue:`4295` +- Revert a change to the CLI that caused it to hide ``ImportError`` + tracebacks when importing the application. :issue:`4307` +- ``app.json_encoder`` and ``json_decoder`` are only passed to + ``dumps`` and ``loads`` if they have custom behavior. This improves + performance, mainly on PyPy. :issue:`4349` +- Clearer error message when ``after_this_request`` is used outside a + request context. :issue:`4333` Version 2.0.2 ------------- -Unreleased +Released 2021-10-04 -- Fix type annotation for ``teardown_request``. :issue:`4093` +- Fix type annotation for ``teardown_*`` methods. :issue:`4093` - Fix type annotation for ``before_request`` and ``before_app_request`` decorators. :issue:`4104` - Fixed the issue where typing requires template global decorators to accept functions with no arguments. :issue:`4098` +- Support View and MethodView instances with async handlers. :issue:`4112` +- Enhance typing of ``app.errorhandler`` decorator. :issue:`4095` +- Fix registering a blueprint twice with differing names. :issue:`4124` +- Fix the type of ``static_folder`` to accept ``pathlib.Path``. + :issue:`4150` +- ``jsonify`` handles ``decimal.Decimal`` by encoding to ``str``. + :issue:`4157` +- Correctly handle raising deferred errors in CLI lazy loading. + :issue:`4096` +- The CLI loader handles ``**kwargs`` in a ``create_app`` function. + :issue:`4170` +- Fix the order of ``before_request`` and other callbacks that trigger + before the view returns. They are called from the app down to the + closest nested blueprint. :issue:`4229` Version 2.0.1 diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 3a9177a46..a3c8b8512 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -12,14 +12,16 @@ to address bugs and feature requests in Flask itself. Use one of the following resources for questions about using Flask or issues with your own code: -- The ``#get-help`` channel on our Discord chat: +- The ``#questions`` channel on our Discord chat: https://discord.gg/pallets - The mailing list flask@python.org for long term discussion or larger issues. - Ask on `Stack Overflow`_. Search with Google first using: ``site:stackoverflow.com flask {search term, exception message, etc.}`` +- Ask on our `GitHub Discussions`_. .. _Stack Overflow: https://stackoverflow.com/questions/tagged/flask?tab=Frequent +.. _GitHub Discussions: https://github.com/pallets/flask/discussions Reporting issues @@ -92,7 +94,7 @@ First time setup .. code-block:: text - git remote add fork https://github.com/{username}/flask + $ git remote add fork https://github.com/{username}/flask - Create a virtualenv. diff --git a/README.rst b/README.rst index 3b1f2fbd4..3d1c3882a 100644 --- a/README.rst +++ b/README.rst @@ -26,7 +26,7 @@ Install and update using `pip`_: $ pip install -U Flask -.. _pip: https://pip.pypa.io/en/stable/quickstart/ +.. _pip: https://pip.pypa.io/en/stable/getting-started/ A Simple Example diff --git a/artwork/LICENSE.rst b/artwork/LICENSE.rst index 605e41cb1..99c58a212 100644 --- a/artwork/LICENSE.rst +++ b/artwork/LICENSE.rst @@ -10,7 +10,7 @@ following conditions are met: 1. Redistributions of source code must retain the above copyright notice and this list of conditions. -3. Neither the name of the copyright holder nor the names of its +2. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/docs/api.rst b/docs/api.rst index e68628783..1a87f8d44 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -168,9 +168,9 @@ thing, like it does for :class:`request` and :class:`session`. :attr:`Flask.app_ctx_globals_class`, which defaults to :class:`ctx._AppCtxGlobals`. - This is a good place to store resources during a request. During - testing, you can use the :ref:`faking-resources` pattern to - pre-configure such resources. + This is a good place to store resources during a request. For + example, a ``before_request`` function could load a user object from + a session id, then set ``g.user`` to be used in the view function. This is a proxy. See :ref:`notes-on-proxies` for more information. @@ -256,7 +256,7 @@ the filter to render data inside `` diff --git a/docs/appcontext.rst b/docs/appcontext.rst index 681764941..b214f254e 100644 --- a/docs/appcontext.rst +++ b/docs/appcontext.rst @@ -8,7 +8,7 @@ a request, CLI command, or other activity. Rather than passing the application around to each function, the :data:`current_app` and :data:`g` proxies are accessed instead. -This is similar to the :doc:`/reqcontext`, which keeps track of +This is similar to :doc:`/reqcontext`, which keeps track of request-level data during a request. A corresponding application context is pushed when a request context is pushed. diff --git a/docs/async-await.rst b/docs/async-await.rst index ad7cbf384..71e5f4522 100644 --- a/docs/async-await.rst +++ b/docs/async-await.rst @@ -18,6 +18,12 @@ defined with ``async def`` and use ``await``. data = await async_db_query(...) return jsonify(data) +Pluggable class-based views also support handlers that are implemented as +coroutines. This applies to the :meth:`~flask.views.View.dispatch_request` +method in views that inherit from the :class:`flask.views.View` class, as +well as all the HTTP method handlers in views that inherit from the +:class:`flask.views.MethodView` class. + .. admonition:: Using ``async`` on Windows on Python 3.8 Python 3.8 has a bug related to asyncio on Windows. If you encounter diff --git a/docs/cli.rst b/docs/cli.rst index 6036cb2d8..3d9149c99 100644 --- a/docs/cli.rst +++ b/docs/cli.rst @@ -27,6 +27,13 @@ environment variable is used to specify how to load the application. $ export FLASK_APP=hello $ flask run + .. group-tab:: Fish + + .. code-block:: text + + $ set -x FLASK_APP hello + $ flask run + .. group-tab:: CMD .. code-block:: text @@ -103,6 +110,11 @@ replaces the :meth:`Flask.run` method in most cases. :: is provided for convenience, but is not designed to be particularly secure, stable, or efficient. See :doc:`/deploying/index` for how to run in production. +If another program is already using port 5000, you'll see +``OSError: [Errno 98]`` or ``OSError: [WinError 10013]`` when the +server tries to start. See :ref:`address-already-in-use` for how to +handle that. + Open a Shell ------------ @@ -152,6 +164,20 @@ reloader. * Debugger is active! * Debugger PIN: 223-456-919 + .. group-tab:: Fish + + .. code-block:: text + + $ set -x FLASK_ENV development + $ flask run + * Serving Flask app "hello" + * Environment: development + * Debug mode: on + * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) + * Restarting with inotify reloader + * Debugger is active! + * Debugger PIN: 223-456-919 + .. group-tab:: CMD .. code-block:: text @@ -203,6 +229,17 @@ separated with ``:``, or ``;`` on Windows. * Running on http://127.0.0.1:8000/ * Detected change in '/path/to/file1', reloading + .. group-tab:: Fish + + .. code-block:: text + + $ flask run --extra-files file1:dirA/file2:dirB/ + # or + $ set -x FLASK_RUN_EXTRA_FILES file1 dirA/file2 dirB/ + $ flask run + * Running on http://127.0.0.1:8000/ + * Detected change in '/path/to/file1', reloading + .. group-tab:: CMD .. code-block:: text @@ -283,6 +320,14 @@ command, instead of ``flask run --port 8000``: $ flask run * Running on http://127.0.0.1:8000/ + .. group-tab:: Fish + + .. code-block:: text + + $ set -x FLASK_RUN_PORT 8000 + $ flask run + * Running on http://127.0.0.1:8000/ + .. group-tab:: CMD .. code-block:: text @@ -330,6 +375,13 @@ configure as expected. $ export FLASK_SKIP_DOTENV=1 $ flask run + .. group-tab:: Fish + + .. code-block:: text + + $ set -x FLASK_SKIP_DOTENV 1 + $ flask run + .. group-tab:: CMD .. code-block:: text @@ -360,6 +412,12 @@ script. Activating the virtualenv will set the variables. $ export FLASK_APP=hello + .. group-tab:: Fish + + Fish, :file:`venv/bin/activate.fish`:: + + $ set -x FLASK_APP hello + .. group-tab:: CMD Windows CMD, :file:`venv\\Scripts\\activate.bat`:: diff --git a/docs/config.rst b/docs/config.rst index 768cf60d8..0b86674d8 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -38,7 +38,7 @@ method:: app.config.update( TESTING=True, - SECRET_KEY=b'_5#y2L"F4Q8z\n\xec]/' + SECRET_KEY='192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf' ) @@ -76,6 +76,13 @@ set :envvar:`FLASK_ENV`: $ export FLASK_ENV=development $ flask run + .. group-tab:: Fish + + .. code-block:: text + + $ set -x FLASK_ENV development + $ flask run + .. group-tab:: CMD .. code-block:: text @@ -180,8 +187,8 @@ The following configuration values are used internally by Flask: application. It should be a long random ``bytes`` or ``str``. For example, copy the output of this to your config:: - $ python -c 'import os; print(os.urandom(16))' - b'_5#y2L"F4Q8z\n\xec]/' + $ python -c 'import secrets; print(secrets.token_hex())' + '192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf' **Do not reveal the secret key when posting questions or committing code.** @@ -445,6 +452,14 @@ in the shell before starting the server: $ flask run * Running on http://127.0.0.1:5000/ + .. group-tab:: Fish + + .. code-block:: text + + $ set -x YOURAPPLICATION_SETTINGS /path/to/settings.cfg + $ flask run + * Running on http://127.0.0.1:5000/ + .. group-tab:: CMD .. code-block:: text @@ -468,7 +483,7 @@ sure to use uppercase letters for your config keys. Here is an example of a configuration file:: # Example configuration - SECRET_KEY = b'_5#y2L"F4Q8z\n\xec]/' + SECRET_KEY = '192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf' Make sure to load the configuration very early on, so that extensions have the ability to access the configuration when starting up. There are other @@ -517,6 +532,15 @@ Environment variables can be set in the shell before starting the server: $ flask run * Running on http://127.0.0.1:5000/ + .. group-tab:: Fish + + .. code-block:: text + + $ set -x SECRET_KEY "5f352379324c22463451387a0aec5d2f" + $ set -x MAIL_ENABLED false + $ flask run + * Running on http://127.0.0.1:5000/ + .. group-tab:: CMD .. code-block:: text diff --git a/docs/debugging.rst b/docs/debugging.rst index a9f984b44..cd955312b 100644 --- a/docs/debugging.rst +++ b/docs/debugging.rst @@ -53,6 +53,13 @@ enables the debugger and reloader. $ export FLASK_ENV=development $ flask run + .. group-tab:: Fish + + .. code-block:: text + + $ set -x FLASK_ENV development + $ flask run + .. group-tab:: CMD .. code-block:: text @@ -69,7 +76,7 @@ enables the debugger and reloader. ``FLASK_ENV`` can only be set as an environment variable. When running from Python code, passing ``debug=True`` enables debug mode, which is -mostly equivalent. Debug mode can be controled separately from +mostly equivalent. Debug mode can be controlled separately from ``FLASK_ENV`` with the ``FLASK_DEBUG`` environment variable as well. .. code-block:: python @@ -106,6 +113,13 @@ When running from the command line: $ export FLASK_ENV=development $ flask run --no-debugger --no-reload + .. group-tab:: Fish + + .. code-block:: text + + $ set -x FLASK_ENV development + $ flask run --no-debugger --no-reload + .. group-tab:: CMD .. code-block:: text diff --git a/docs/deploying/asgi.rst b/docs/deploying/asgi.rst index c7e04027a..39cd76b72 100644 --- a/docs/deploying/asgi.rst +++ b/docs/deploying/asgi.rst @@ -5,7 +5,7 @@ ASGI If you'd like to use an ASGI server you will need to utilise WSGI to ASGI middleware. The asgiref -[WsgiToAsgi](https://github.com/django/asgiref#wsgi-to-asgi-adapter) +`WsgiToAsgi `_ adapter is recommended as it integrates with the event loop used for Flask's :ref:`async_await` support. You can use the adapter by wrapping the Flask app, @@ -21,7 +21,7 @@ wrapping the Flask app, asgi_app = WsgiToAsgi(app) -and then serving the ``asgi_app`` with the asgi server, e.g. using +and then serving the ``asgi_app`` with the ASGI server, e.g. using `Hypercorn `_, .. sourcecode:: text diff --git a/docs/deploying/fastcgi.rst b/docs/deploying/fastcgi.rst index ef2201c86..d3614d377 100644 --- a/docs/deploying/fastcgi.rst +++ b/docs/deploying/fastcgi.rst @@ -234,5 +234,5 @@ python path. Common problems are: .. _nginx: https://nginx.org/ .. _lighttpd: https://www.lighttpd.net/ -.. _cherokee: http://cherokee-project.com/ +.. _cherokee: https://cherokee-project.com/ .. _flup: https://pypi.org/project/flup/ diff --git a/docs/deploying/uwsgi.rst b/docs/deploying/uwsgi.rst index 22930d7bd..b6958dc09 100644 --- a/docs/deploying/uwsgi.rst +++ b/docs/deploying/uwsgi.rst @@ -37,7 +37,7 @@ If your application is accessible at root level, you can use a single ``/`` instead of ``/yourapplication``. ``myapp`` refers to the name of the file of your flask application (without extension) or the module which provides ``app``. ``app`` is the callable inside of your application (usually -the line reads ``app = Flask(__name__)``. +the line reads ``app = Flask(__name__)``). If you want to deploy your flask application inside of a virtual environment, you need to also add ``--virtualenv /path/to/virtual/environment``. You might @@ -67,5 +67,5 @@ to have it in the URL root its a bit simpler:: .. _nginx: https://nginx.org/ .. _lighttpd: https://www.lighttpd.net/ -.. _cherokee: http://cherokee-project.com/ +.. _cherokee: https://cherokee-project.com/ .. _uwsgi: https://uwsgi-docs.readthedocs.io/en/latest/ diff --git a/docs/locales/zh_CN/LC_MESSAGES/api.po b/docs/locales/zh_CN/LC_MESSAGES/api.po index a092df4d5..fd4c2379f 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/api.po +++ b/docs/locales/zh_CN/LC_MESSAGES/api.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-30 19:27+0000\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: zh_CN \n" @@ -134,9 +134,9 @@ msgstr "" #: flask.app.Flask.handle_user_exception flask.app.Flask.inject_url_defaults #: flask.app.Flask.log_exception flask.app.Flask.make_config #: flask.app.Flask.make_response flask.app.Flask.open_instance_resource -#: flask.app.Flask.process_response flask.app.Flask.raise_routing_exception -#: flask.app.Flask.register_blueprint flask.app.Flask.request_context -#: flask.app.Flask.run flask.app.Flask.select_jinja_autoescape +#: flask.app.Flask.process_response flask.app.Flask.register_blueprint +#: flask.app.Flask.request_context flask.app.Flask.run +#: flask.app.Flask.select_jinja_autoescape #: flask.app.Flask.shell_context_processor flask.app.Flask.should_ignore_error #: flask.app.Flask.teardown_appcontext flask.app.Flask.template_filter #: flask.app.Flask.template_global flask.app.Flask.template_test @@ -168,8 +168,8 @@ msgstr "" #: flask.cli.FlaskGroup flask.cli.FlaskGroup.main flask.cli.load_dotenv #: flask.cli.run_command flask.cli.shell_command flask.config.Config #: flask.config.Config.from_envvar flask.config.Config.from_file -#: flask.config.Config.from_json flask.config.Config.from_mapping -#: flask.config.Config.from_object flask.config.Config.from_pyfile +#: flask.config.Config.from_mapping flask.config.Config.from_object +#: flask.config.Config.from_prefixed_env flask.config.Config.from_pyfile #: flask.config.Config.get_namespace flask.ctx.AppContext #: flask.ctx.AppContext.pop flask.ctx.RequestContext #: flask.ctx.RequestContext.pop flask.ctx._AppCtxGlobals.get @@ -177,13 +177,13 @@ msgstr "" #: flask.ctx.after_this_request flask.ctx.copy_current_request_context #: flask.helpers.flash flask.helpers.get_flashed_messages #: flask.helpers.get_template_attribute flask.helpers.make_response -#: flask.helpers.safe_join flask.helpers.send_file -#: flask.helpers.send_from_directory flask.helpers.stream_with_context -#: flask.helpers.url_for flask.json.JSONEncoder.default flask.json.dump -#: flask.json.dumps flask.json.jsonify flask.json.load flask.json.loads -#: flask.json.tag.JSONTag flask.json.tag.JSONTag.check -#: flask.json.tag.JSONTag.tag flask.json.tag.JSONTag.to_json -#: flask.json.tag.JSONTag.to_python flask.json.tag.TaggedJSONSerializer.dumps +#: flask.helpers.send_file flask.helpers.send_from_directory +#: flask.helpers.stream_with_context flask.helpers.url_for +#: flask.json.JSONEncoder.default flask.json.dump flask.json.dumps +#: flask.json.jsonify flask.json.load flask.json.loads flask.json.tag.JSONTag +#: flask.json.tag.JSONTag.check flask.json.tag.JSONTag.tag +#: flask.json.tag.JSONTag.to_json flask.json.tag.JSONTag.to_python +#: flask.json.tag.TaggedJSONSerializer.dumps #: flask.json.tag.TaggedJSONSerializer.loads #: flask.json.tag.TaggedJSONSerializer.register #: flask.json.tag.TaggedJSONSerializer.tag @@ -199,7 +199,8 @@ msgstr "" #: flask.scaffold.Scaffold.teardown_request #: flask.scaffold.Scaffold.url_defaults #: flask.scaffold.Scaffold.url_value_preprocessor flask.sessions.NullSession -#: flask.sessions.SecureCookieSession flask.sessions.SecureCookieSession.get +#: flask.sessions.NullSession._fail flask.sessions.SecureCookieSession +#: flask.sessions.SecureCookieSession.get #: flask.sessions.SecureCookieSession.setdefault #: flask.sessions.SecureCookieSessionInterface.open_session #: flask.sessions.SecureCookieSessionInterface.save_session @@ -335,9 +336,8 @@ msgstr "" #: flask.app.Flask.make_default_options_response flask.app.Flask.make_response #: flask.app.Flask.make_shell_context flask.app.Flask.open_instance_resource #: flask.app.Flask.preprocess_request flask.app.Flask.process_response -#: flask.app.Flask.raise_routing_exception flask.app.Flask.register_blueprint -#: flask.app.Flask.request_context flask.app.Flask.run -#: flask.app.Flask.select_jinja_autoescape +#: flask.app.Flask.register_blueprint flask.app.Flask.request_context +#: flask.app.Flask.run flask.app.Flask.select_jinja_autoescape #: flask.app.Flask.shell_context_processor flask.app.Flask.should_ignore_error #: flask.app.Flask.teardown_appcontext flask.app.Flask.template_filter #: flask.app.Flask.template_global flask.app.Flask.template_test @@ -368,8 +368,8 @@ msgstr "" #: flask.blueprints.BlueprintSetupState.add_url_rule flask.cli.AppGroup #: flask.cli.run_command flask.cli.shell_command flask.config.Config #: flask.config.Config.from_envvar flask.config.Config.from_file -#: flask.config.Config.from_json flask.config.Config.from_mapping -#: flask.config.Config.from_object flask.config.Config.from_pyfile +#: flask.config.Config.from_mapping flask.config.Config.from_object +#: flask.config.Config.from_prefixed_env flask.config.Config.from_pyfile #: flask.config.Config.get_namespace flask.ctx.AppContext #: flask.ctx.AppContext.pop flask.ctx.AppContext.push flask.ctx.RequestContext #: flask.ctx.RequestContext.copy flask.ctx.RequestContext.match_request @@ -379,13 +379,13 @@ msgstr "" #: flask.ctx.copy_current_request_context flask.ctx.has_app_context #: flask.ctx.has_request_context flask.helpers.flash #: flask.helpers.get_flashed_messages flask.helpers.get_template_attribute -#: flask.helpers.make_response flask.helpers.safe_join -#: flask.helpers.send_from_directory flask.helpers.stream_with_context -#: flask.helpers.url_for flask.json.JSONEncoder.default flask.json.dump -#: flask.json.dumps flask.json.jsonify flask.json.load flask.json.loads -#: flask.json.tag.JSONTag flask.json.tag.JSONTag.check -#: flask.json.tag.JSONTag.tag flask.json.tag.JSONTag.to_json -#: flask.json.tag.JSONTag.to_python flask.json.tag.TaggedJSONSerializer +#: flask.helpers.make_response flask.helpers.send_from_directory +#: flask.helpers.stream_with_context flask.helpers.url_for +#: flask.json.JSONEncoder.default flask.json.dump flask.json.dumps +#: flask.json.jsonify flask.json.load flask.json.loads flask.json.tag.JSONTag +#: flask.json.tag.JSONTag.check flask.json.tag.JSONTag.tag +#: flask.json.tag.JSONTag.to_json flask.json.tag.JSONTag.to_python +#: flask.json.tag.TaggedJSONSerializer #: flask.json.tag.TaggedJSONSerializer.dumps #: flask.json.tag.TaggedJSONSerializer.loads #: flask.json.tag.TaggedJSONSerializer.register @@ -402,7 +402,8 @@ msgstr "" #: flask.scaffold.Scaffold.teardown_request #: flask.scaffold.Scaffold.url_defaults #: flask.scaffold.Scaffold.url_value_preprocessor flask.sessions.NullSession -#: flask.sessions.SecureCookieSession flask.sessions.SecureCookieSession.get +#: flask.sessions.NullSession._fail flask.sessions.SecureCookieSession +#: flask.sessions.SecureCookieSession.get #: flask.sessions.SecureCookieSession.setdefault #: flask.sessions.SecureCookieSessionInterface.open_session #: flask.sessions.SecureCookieSessionInterface.save_session @@ -956,7 +957,7 @@ msgid "" "will be logged and otherwise ignored." msgstr "" -#: flask.app.Flask.finalize_request flask.app.Flask.raise_routing_exception +#: flask.app.Flask.finalize_request #: flask.app.Flask.try_trigger_before_first_request_functions of msgid "internal" msgstr "" @@ -1048,7 +1049,7 @@ msgstr "" #: flask.app.Flask.handle_http_exception:10 of msgid "" -"Exceptions are looked up by code *and* by MRO, so ``HTTPExcpetion`` " +"Exceptions are looked up by code *and* by MRO, so ``HTTPException`` " "subclasses can be handled with a catch-all handler for the base " "``HTTPException``." msgstr "" @@ -1398,9 +1399,9 @@ msgid "a :attr:`response_class` object." msgstr "" #: ../../docstring flask.app.Flask.process_response flask.cli.load_dotenv -#: flask.config.Config.from_envvar flask.helpers.safe_join -#: flask.testing.FlaskCliRunner.invoke markupsafe._speedups.escape of -#: werkzeug.wrappers.request.Request.application +#: flask.config.Config.from_envvar flask.config.Config.from_file +#: flask.config.Config.from_pyfile flask.testing.FlaskCliRunner.invoke +#: markupsafe._speedups.escape of werkzeug.wrappers.request.Request.application #: werkzeug.wrappers.request.Request.from_values #: werkzeug.wrappers.response.Response.force_type #: werkzeug.wrappers.response.Response.from_app @@ -1426,14 +1427,6 @@ msgstr "" msgid "Shortcut for :meth:`route` with ``methods=[\"PUT\"]``." msgstr "" -#: flask.app.Flask.raise_routing_exception:1 of -msgid "" -"Exceptions that are recording during routing are reraised with this " -"method. During debug we are not reraising redirect requests for non " -"``GET``, ``HEAD``, or ``OPTIONS`` requests and we're raising a different " -"error instead to help debug situations." -msgstr "" - #: flask.app.Flask.register_blueprint:1 of msgid "" "Register a :class:`~flask.Blueprint` on the application. Keyword " @@ -1783,9 +1776,9 @@ msgstr "" #: flask.scaffold.Scaffold.teardown_request:18 of msgid "" -"Teardown functions must avoid raising exceptions, since they . If they " -"execute code that might fail they will have to surround the execution of " -"these code by try/except statements and log occurring errors." +"Teardown functions must avoid raising exceptions. If they execute code " +"that might fail they will have to surround the execution of that code " +"with try/except statements and log any errors." msgstr "" #: flask.scaffold.Scaffold.teardown_request:23 of @@ -1951,7 +1944,9 @@ msgid "added support for ``with`` block usage for the client." msgstr "" #: ../../docstring flask.Flask.test_client_class:1 of -msgid "the test client that is used with when `test_client` is used." +msgid "" +"The :meth:`test_client` method creates an instance of this test client " +"class. Defaults to :class:`~flask.testing.FlaskClient`." msgstr "" #: flask.app.Flask.test_request_context:1 of @@ -2821,7 +2816,7 @@ msgstr "" #: werkzeug.wrappers.response.Response.get_json:3 msgid "" "If the mimetype does not indicate JSON (:mimetype:`application/json`, see" -" :meth:`is_json`), this returns ``None``." +" :attr:`is_json`), this returns ``None``." msgstr "" #: of werkzeug.wrappers.request.Request.get_json:7 @@ -2928,7 +2923,7 @@ msgstr "" #: flask.Request.json:1 flask.Response.json:1 of msgid "" "The parsed JSON data if :attr:`mimetype` indicates JSON " -"(:mimetype:`application/json`, see :meth:`is_json`)." +"(:mimetype:`application/json`, see :attr:`is_json`)." msgstr "" #: flask.Request.json:4 flask.Response.json:4 of @@ -3339,13 +3334,27 @@ msgid "" "the header is not set." msgstr "" -#: ../../docstring flask.Response.content_security_policy:1 of +#: flask.Response.content_security_policy:1 of +msgid "" +"The ``Content-Security-Policy`` header as a " +":class:`~werkzeug.datastructures.ContentSecurityPolicy` object. Available" +" even if the header is not set." +msgstr "" + +#: flask.Response.content_security_policy:5 of msgid "" "The Content-Security-Policy header adds an additional layer of security " "to help detect and mitigate certain types of attacks." msgstr "" -#: ../../docstring flask.Response.content_security_policy_report_only:1 of +#: flask.Response.content_security_policy_report_only:1 of +msgid "" +"The ``Content-Security-policy-report-only`` header as a " +":class:`~werkzeug.datastructures.ContentSecurityPolicy` object. Available" +" even if the header is not set." +msgstr "" + +#: flask.Response.content_security_policy_report_only:5 of msgid "" "The Content-Security-Policy-Report-Only header adds a csp policy that is " "not enforced but is reported thereby helping detect certain types of " @@ -3929,6 +3938,16 @@ msgid "" "to assign :attr:`flask.Flask.session_interface`::" msgstr "" +#: flask.sessions.SessionInterface:27 of +msgid "" +"Multiple requests with the same session may be sent and handled " +"concurrently. When implementing a new session interface, consider whether" +" reads or writes to the backing store must be synchronized. There is no " +"guarantee on the order in which the session for each request is opened or" +" saved, it will occur in the order that requests begin and end " +"processing." +msgstr "" + #: flask.sessions.SessionInterface.get_cookie_domain:1 of msgid "Returns the domain that should be set for the session cookie." msgstr "" @@ -4024,10 +4043,23 @@ msgstr "" #: flask.sessions.SecureCookieSessionInterface.open_session:1 #: flask.sessions.SessionInterface.open_session:1 of msgid "" -"This method has to be implemented and must either return ``None`` in case" -" the loading failed because of a configuration error or an instance of a " -"session object which implements a dictionary like interface + the methods" -" and attributes on :class:`SessionMixin`." +"This is called at the beginning of each request, after pushing the " +"request context, before matching the URL." +msgstr "" + +#: flask.sessions.SecureCookieSessionInterface.open_session:4 +#: flask.sessions.SessionInterface.open_session:4 of +msgid "" +"This must return an object which implements a dictionary-like interface " +"as well as the :class:`SessionMixin` interface." +msgstr "" + +#: flask.sessions.SecureCookieSessionInterface.open_session:7 +#: flask.sessions.SessionInterface.open_session:7 of +msgid "" +"This will return ``None`` to indicate that loading failed in some way " +"that is not immediately an error. The request context will fall back to " +"using :meth:`make_null_session` in this case." msgstr "" #: ../../docstring flask.sessions.SessionInterface.pickle_based:1 of @@ -4040,9 +4072,9 @@ msgstr "" #: flask.sessions.SecureCookieSessionInterface.save_session:1 #: flask.sessions.SessionInterface.save_session:1 of msgid "" -"This is called for actual sessions returned by :meth:`open_session` at " -"the end of the request. This is still called during a request context so" -" if you absolutely need access to the request you can do that." +"This is called at the end of each request, after generating a response, " +"before removing the request context. It is skipped if " +":meth:`is_null_session` returns ``True``." msgstr "" #: flask.sessions.SessionInterface.should_set_cookie:1 of @@ -4105,7 +4137,7 @@ msgid "" "different users." msgstr "" -#: flask.sessions.SecureCookieSession.get:1 +#: flask.sessions.NullSession._fail:3 flask.sessions.SecureCookieSession.get:1 #: flask.sessions.SecureCookieSession.setdefault:3 of msgid "Return the value for key if key is in the dictionary, else default." msgstr "" @@ -4119,6 +4151,7 @@ msgid "" "response if this is ``True``." msgstr "" +#: flask.sessions.NullSession._fail:1 #: flask.sessions.SecureCookieSession.setdefault:1 of msgid "Insert key with a value of default if key is not in the dictionary." msgstr "" @@ -4130,6 +4163,27 @@ msgid "" "fail on setting." msgstr "" +#: flask.sessions.NullSession._fail:1 of +msgid "If key is not found, d is returned if given, otherwise KeyError is raised" +msgstr "" + +#: flask.sessions.NullSession._fail:1 of +msgid "Remove and return a (key, value) pair as a 2-tuple." +msgstr "" + +#: flask.sessions.NullSession._fail:3 of +msgid "" +"Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if" +" the dict is empty." +msgstr "" + +#: flask.sessions.NullSession._fail:1 of +msgid "" +"If E is present and has a .keys() method, then does: for k in E: D[k] = " +"E[k] If E is present and lacks a .keys() method, then does: for k, v in " +"E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]" +msgstr "" + #: flask.sessions.SessionMixin:1 of msgid "Expands a basic dictionary with session attributes." msgstr "" @@ -4314,9 +4368,9 @@ msgstr "" #: ../../api.rst:171 msgid "" -"This is a good place to store resources during a request. During testing," -" you can use the :ref:`faking-resources` pattern to pre-configure such " -"resources." +"This is a good place to store resources during a request. For example, a " +"``before_request`` function could load a user object from a session id, " +"then set ``g.user`` to be used in the view function." msgstr "" #: ../../api.rst:175 ../../api.rst:199 @@ -4828,24 +4882,6 @@ msgstr "" msgid "``path`` replaces the ``filename`` parameter." msgstr "" -#: flask.helpers.safe_join:1 of -msgid "" -"Safely join zero or more untrusted path components to a base directory to" -" avoid escaping the base directory." -msgstr "" - -#: flask.helpers.safe_join:4 of -msgid "The trusted base directory." -msgstr "" - -#: flask.helpers.safe_join:5 of -msgid "The untrusted path components relative to the base directory." -msgstr "" - -#: flask.helpers.safe_join:7 of -msgid "A safe path, otherwise ``None``." -msgstr "" - #: ../../docstring markupsafe._speedups.escape:1 of msgid "" "Replace the characters ``&``, ``<``, ``>``, ``'``, and ``\"`` in the " @@ -5074,7 +5110,11 @@ msgid "" "will be formatted to be easier to read." msgstr "" -#: flask.json.jsonify:43 of +#: flask.json.dumps:11 flask.json.jsonify:43 of +msgid ":class:`decimal.Decimal` is supported by converting to a string." +msgstr "" + +#: flask.json.jsonify:46 of msgid "" "Added support for serializing top-level arrays. This introduces a " "security risk in ancient browsers. See :ref:`security-json`." @@ -5102,11 +5142,11 @@ msgstr "" msgid "Extra arguments passed to :func:`json.dumps`." msgstr "" -#: flask.json.dumps:11 of +#: flask.json.dumps:14 of msgid "``encoding`` is deprecated and will be removed in Flask 2.1." msgstr "" -#: flask.json.dumps:14 flask.json.loads:15 of +#: flask.json.dumps:17 flask.json.loads:15 of msgid "" "``app`` can be passed directly, rather than requiring an app context for " "configuration." @@ -5484,8 +5524,9 @@ msgstr "" msgid "set to ``True`` if you want silent failure for missing files." msgstr "" -#: flask.config.Config.from_envvar:10 of -msgid "bool. ``True`` if able to load config, ``False`` otherwise." +#: flask.config.Config.from_envvar:10 flask.config.Config.from_file:20 +#: flask.config.Config.from_pyfile:10 of +msgid "``True`` if the file was loaded successfully." msgstr "" #: flask.config.Config.from_file:1 of @@ -5495,42 +5536,26 @@ msgid "" " method." msgstr "" -#: flask.config.Config.from_file:10 of +#: flask.config.Config.from_file:13 of msgid "" "The path to the data file. This can be an absolute path or relative to " "the config root path." msgstr "" -#: flask.config.Config.from_file:12 of +#: flask.config.Config.from_file:15 of msgid "" "A callable that takes a file handle and returns a mapping of loaded data " "from the file." msgstr "" -#: flask.config.Config.from_file:16 flask.config.Config.from_json:6 of +#: flask.config.Config.from_file:19 of msgid "Ignore the file if it doesn't exist." msgstr "" -#: flask.config.Config.from_json:1 of -msgid "" -"Update the values in the config from a JSON file. The loaded data is " -"passed to the :meth:`from_mapping` method." -msgstr "" - -#: flask.config.Config.from_json:4 of -msgid "" -"The path to the JSON file. This can be an absolute path or relative to " -"the config root path." -msgstr "" - -#: flask.config.Config.from_json:8 of -msgid "" -"Will be removed in Flask 2.1. Use :meth:`from_file` instead. This was " -"removed early in 2.0.0, was added back in 2.0.1." -msgstr "" - #: flask.config.Config.from_mapping:1 of -msgid "Updates the config like :meth:`update` ignoring items with non-upper keys." +msgid "" +"Updates the config like :meth:`update` ignoring items with non-upper " +"keys. :return: Always returns ``True``." msgstr "" #: flask.config.Config.from_object:1 of @@ -5584,6 +5609,44 @@ msgstr "" msgid "an import name or object" msgstr "" +#: flask.config.Config.from_prefixed_env:1 of +msgid "" +"Load any environment variables that start with ``FLASK_``, dropping the " +"prefix from the env key for the config key. Values are passed through a " +"loading function to attempt to convert them to more specific types than " +"strings." +msgstr "" + +#: flask.config.Config.from_prefixed_env:6 of +msgid "Keys are loaded in :func:`sorted` order." +msgstr "" + +#: flask.config.Config.from_prefixed_env:8 of +msgid "" +"The default loading function attempts to parse values as any valid JSON " +"type, including dicts and lists." +msgstr "" + +#: flask.config.Config.from_prefixed_env:11 of +msgid "" +"Specific items in nested dicts can be set by separating the keys with " +"double underscores (``__``). If an intermediate key doesn't exist, it " +"will be initialized to an empty dict." +msgstr "" + +#: flask.config.Config.from_prefixed_env:15 of +msgid "" +"Load env vars that start with this prefix, separated with an underscore " +"(``_``)." +msgstr "" + +#: flask.config.Config.from_prefixed_env:17 of +msgid "" +"Pass each string value to this function and use the returned value as the" +" config value. If any error is raised it is ignored and the value remains" +" a string. The default is :func:`json.loads`." +msgstr "" + #: flask.config.Config.from_pyfile:1 of msgid "" "Updates the values in the config from a Python file. This function " @@ -5597,7 +5660,7 @@ msgid "" " filename relative to the root path." msgstr "" -#: flask.config.Config.from_pyfile:11 of +#: flask.config.Config.from_pyfile:12 of msgid "`silent` parameter." msgstr "" @@ -6613,3 +6676,116 @@ msgstr "" #~ msgid "Raises" #~ msgstr "" + +#~ msgid "" +#~ "Exceptions are looked up by code " +#~ "*and* by MRO, so ``HTTPExcpetion`` " +#~ "subclasses can be handled with a " +#~ "catch-all handler for the base " +#~ "``HTTPException``." +#~ msgstr "" + +#~ msgid "" +#~ "Exceptions that are recording during " +#~ "routing are reraised with this method." +#~ " During debug we are not reraising" +#~ " redirect requests for non ``GET``, " +#~ "``HEAD``, or ``OPTIONS`` requests and " +#~ "we're raising a different error instead" +#~ " to help debug situations." +#~ msgstr "" + +#~ msgid "" +#~ "Teardown functions must avoid raising " +#~ "exceptions, since they . If they " +#~ "execute code that might fail they " +#~ "will have to surround the execution " +#~ "of these code by try/except statements" +#~ " and log occurring errors." +#~ msgstr "" + +#~ msgid "the test client that is used with when `test_client` is used." +#~ msgstr "" + +#~ msgid "" +#~ "If the mimetype does not indicate " +#~ "JSON (:mimetype:`application/json`, see " +#~ ":meth:`is_json`), this returns ``None``." +#~ msgstr "" + +#~ msgid "" +#~ "The parsed JSON data if :attr:`mimetype`" +#~ " indicates JSON (:mimetype:`application/json`, " +#~ "see :meth:`is_json`)." +#~ msgstr "" + +#~ msgid "" +#~ "This method has to be implemented " +#~ "and must either return ``None`` in " +#~ "case the loading failed because of " +#~ "a configuration error or an instance " +#~ "of a session object which implements " +#~ "a dictionary like interface + the " +#~ "methods and attributes on " +#~ ":class:`SessionMixin`." +#~ msgstr "" + +#~ msgid "" +#~ "This is called for actual sessions " +#~ "returned by :meth:`open_session` at the " +#~ "end of the request. This is still" +#~ " called during a request context so" +#~ " if you absolutely need access to " +#~ "the request you can do that." +#~ msgstr "" + +#~ msgid "" +#~ "This is a good place to store " +#~ "resources during a request. During " +#~ "testing, you can use the :ref" +#~ ":`faking-resources` pattern to pre-" +#~ "configure such resources." +#~ msgstr "" + +#~ msgid "" +#~ "Safely join zero or more untrusted " +#~ "path components to a base directory " +#~ "to avoid escaping the base directory." +#~ msgstr "" + +#~ msgid "The trusted base directory." +#~ msgstr "" + +#~ msgid "The untrusted path components relative to the base directory." +#~ msgstr "" + +#~ msgid "A safe path, otherwise ``None``." +#~ msgstr "" + +#~ msgid "bool. ``True`` if able to load config, ``False`` otherwise." +#~ msgstr "" + +#~ msgid "" +#~ "Update the values in the config " +#~ "from a JSON file. The loaded data" +#~ " is passed to the :meth:`from_mapping` " +#~ "method." +#~ msgstr "" + +#~ msgid "" +#~ "The path to the JSON file. This" +#~ " can be an absolute path or " +#~ "relative to the config root path." +#~ msgstr "" + +#~ msgid "" +#~ "Will be removed in Flask 2.1. Use" +#~ " :meth:`from_file` instead. This was " +#~ "removed early in 2.0.0, was added " +#~ "back in 2.0.1." +#~ msgstr "" + +#~ msgid "" +#~ "Updates the config like :meth:`update` " +#~ "ignoring items with non-upper keys." +#~ msgstr "" diff --git a/docs/locales/zh_CN/LC_MESSAGES/appcontext.po b/docs/locales/zh_CN/LC_MESSAGES/appcontext.po index 1f440ac01..06a9b0705 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/appcontext.po +++ b/docs/locales/zh_CN/LC_MESSAGES/appcontext.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: rosekc \n" "Language-Team: zh_CN \n" @@ -28,18 +28,16 @@ msgid "" "application around to each function, the :data:`current_app` and " ":data:`g` proxies are accessed instead." msgstr "" -"应用上下文在请求、命令行命令以及其他活动期间保持对应用层面数据的追踪。相" -"比起将应用上下文传递到每个函数当中,Flask 使用了 :data:`current_app` 和 :" -"data:`g` 这两个代理对象来访问应用上下文。" +"应用上下文在请求、命令行命令以及其他活动期间保持对应用层面数据的追踪。相比起将应用上下文传递到每个函数当中,Flask 使用了 " +":data:`current_app` 和 :data:`g` 这两个代理对象来访问应用上下文。" #: ../../appcontext.rst:11 +#, fuzzy msgid "" -"This is similar to the :doc:`/reqcontext`, which keeps track of request-" -"level data during a request. A corresponding application context is " -"pushed when a request context is pushed." -msgstr "" -"这与在请求当中跟踪请求层面数据的 :doc:`/reqcontext` 类似。在一个请" -"求上下文被推入线程局部栈时,对应的应用上下文也被推入。" +"This is similar to :doc:`/reqcontext`, which keeps track of request-level" +" data during a request. A corresponding application context is pushed " +"when a request context is pushed." +msgstr "这与在请求当中跟踪请求层面数据的 :doc:`/reqcontext` 类似。在一个请求上下文被推入线程局部栈时,对应的应用上下文也被推入。" #: ../../appcontext.rst:16 msgid "Purpose of the Context" @@ -55,11 +53,10 @@ msgid "" "writing reusable :doc:`blueprints ` or :doc:`extensions " "` there won't be an ``app`` instance to import at all." msgstr "" -":class:`Flask` 应用对象所拥有的属性(attributes),如 :attr:`~Flask.config`," -"在视图函数与 :doc:`CLI 命令 ` 中会用到。然而,在项目的模块里导入" -"(import) ``app`` 可能会带来循环导入的问题。当使用 :doc:`应用工厂模式 ` 、编写可重用的 :doc:`蓝图 ` 或者 :" -"doc:`扩展 `,``app`` 实例将完全无法被导入。" +":class:`Flask` 应用对象所拥有的属性(attributes),如 :attr:`~Flask.config`,在视图函数与 " +":doc:`CLI 命令 ` 中会用到。然而,在项目的模块里导入(import) ``app`` 可能会带来循环导入的问题。当使用 " +":doc:`应用工厂模式 ` 、编写可重用的 :doc:`蓝图 ` 或者" +" :doc:`扩展 `,``app`` 实例将完全无法被导入。" #: ../../appcontext.rst:27 msgid "" @@ -67,8 +64,8 @@ msgid "" "referring to an ``app`` directly, you use the :data:`current_app` proxy, " "which points to the application handling the current activity." msgstr "" -"Flask 使用 *应用上下文* 来解决这个问题。在这种情况下,使用指向当前活动的" -"应用对象的代理 :data:`current_app` ,而不是直接引用 ``app``。" +"Flask 使用 *应用上下文* 来解决这个问题。在这种情况下,使用指向当前活动的应用对象的代理 :data:`current_app` " +",而不是直接引用 ``app``。" #: ../../appcontext.rst:31 msgid "" @@ -76,8 +73,8 @@ msgid "" "request. View functions, error handlers, and other functions that run " "during a request will have access to :data:`current_app`." msgstr "" -"Flask 在处理请求时候会自动 *推入* 一个应用上下文。视图函数、错误处理器、还" -"有其他在请求中运行的函数将可以访问 :data:`current_app`。" +"Flask 在处理请求时候会自动 *推入* 一个应用上下文。视图函数、错误处理器、还有其他在请求中运行的函数将可以访问 " +":data:`current_app`。" #: ../../appcontext.rst:35 msgid "" @@ -99,17 +96,14 @@ msgid "" " it pops the request context then the application context. Typically, an " "application context will have the same lifetime as a request." msgstr "" -"应用上下文会在必要的时候创建以及销毁。当 Flask 应用准备处理一个请求时,将" -"推入一个应用上下文以及 :doc:`请求上下文 `。当请求结束的时候,弹出" -"应用上下文以及请求上下文。通常来说,一个应用上下文与请求上下文拥有一致" -"的生命周期。" +"应用上下文会在必要的时候创建以及销毁。当 Flask 应用准备处理一个请求时,将推入一个应用上下文以及 :doc:`请求上下文 " +"`。当请求结束的时候,弹出应用上下文以及请求上下文。通常来说,一个应用上下文与请求上下文拥有一致的生命周期。" #: ../../appcontext.rst:49 msgid "" "See :doc:`/reqcontext` for more information about how the contexts work " "and the full life cycle of a request." -msgstr "" -"关于上下文的工作原理以及请求的完整生命周期的更多信息,参见 :doc:`/reqcontext`。" +msgstr "关于上下文的工作原理以及请求的完整生命周期的更多信息,参见 :doc:`/reqcontext`。" #: ../../appcontext.rst:54 msgid "Manually Push a Context" @@ -119,9 +113,7 @@ msgstr "手动推入一个上下文" msgid "" "If you try to access :data:`current_app`, or anything that uses it, " "outside an application context, you'll get this error message:" -msgstr "" -"若在应用上下文之外的地方尝试访问 :data:`current_app` ,或在任何" -"使用此对象的情况下,会收到这样的错误信息:" +msgstr "若在应用上下文之外的地方尝试访问 :data:`current_app` ,或在任何使用此对象的情况下,会收到这样的错误信息:" #: ../../appcontext.rst:67 msgid "" @@ -131,18 +123,15 @@ msgid "" "``with`` block, and everything that runs in the block will have access to" " :data:`current_app`. ::" msgstr "" -"如果在配置应用的时候(如初始化扩展)看到这样的错误信息,可以手动推入一个上下" -"文以访问 ``app``。在 ``with`` 语句中使用 :meth:`~Flask." -"app_context` 上下文管理器对象,所有在块内的运行的代码将可以访问 :data:`current_app`:" +"如果在配置应用的时候(如初始化扩展)看到这样的错误信息,可以手动推入一个上下文以访问 ``app``。在 ``with`` 语句中使用 " +":meth:`~Flask.app_context` 上下文管理器对象,所有在块内的运行的代码将可以访问 :data:`current_app`:" #: ../../appcontext.rst:81 msgid "" "If you see that error somewhere else in your code not related to " "configuring the application, it most likely indicates that you should " "move that code into a view function or CLI command." -msgstr "" -"如果你在配置应用以外场景遇到这个错误,绝大多数情况下意味着这些代码应该转移到" -"视图函数以及命令行命令下。" +msgstr "如果你在配置应用以外场景遇到这个错误,绝大多数情况下意味着这些代码应该转移到视图函数以及命令行命令下。" #: ../../appcontext.rst:87 msgid "Storing Data" @@ -155,9 +144,8 @@ msgid "" "purpose. It is a simple namespace object that has the same lifetime as an" " application context." msgstr "" -"在请求中或者命令行命令里,应用上下文是存储通用数据的好地方。" -"Flask 为此提供了 :data:`g 对象` 。这是一个简单的命名空间对象," -"与应用上下文有同样的生命周期。" +"在请求中或者命令行命令里,应用上下文是存储通用数据的好地方。Flask 为此提供了 :data:`g 对象` " +"。这是一个简单的命名空间对象,与应用上下文有同样的生命周期。" #: ../../appcontext.rst:95 msgid "" @@ -167,9 +155,8 @@ msgid "" "requests. Use the :data:`session` or a database to store data across " "requests." msgstr "" -"``g`` 表示 “global”(全局)的意思,这也意味着数据 *在上下文中* 是属于全局的。" -"在上下文结束的时候, ``g`` 对象中的数据会丢失,因此这不是请求之间存放数据的好地方。" -"这时候可以使用 :data:`session` 或者数据库来存放跨请求的数据。" +"``g`` 表示 “global”(全局)的意思,这也意味着数据 *在上下文中* 是属于全局的。在上下文结束的时候, ``g`` " +"对象中的数据会丢失,因此这不是请求之间存放数据的好地方。这时候可以使用 :data:`session` 或者数据库来存放跨请求的数据。" #: ../../appcontext.rst:101 msgid "A common use for :data:`g` is to manage resources during a request." @@ -179,16 +166,15 @@ msgstr "一种使用 :data:`g` 的常见场景是管理一个请求中的资源 msgid "" "``get_X()`` creates resource ``X`` if it does not exist, caching it as " "``g.X``." -msgstr "" -"``get_X()`` 在资源 ``X`` 不存在的时候创建了资源 ``X``,将其缓存到 ``g.X``。" +msgstr "``get_X()`` 在资源 ``X`` 不存在的时候创建了资源 ``X``,将其缓存到 ``g.X``。" #: ../../appcontext.rst:105 msgid "" "``teardown_X()`` closes or otherwise deallocates the resource if it " "exists. It is registered as a :meth:`~Flask.teardown_appcontext` handler." msgstr "" -"``teardown_X()`` 在资源存在的时候关闭或者释放它。函数被注册为 :meth:`~Flask." -"teardown_appcontext` 钩子函数。" +"``teardown_X()`` 在资源存在的时候关闭或者释放它。函数被注册为 " +":meth:`~Flask.teardown_appcontext` 钩子函数。" #: ../../appcontext.rst:109 msgid "For example, you can manage a database connection using this pattern::" @@ -199,25 +185,19 @@ msgid "" "During a request, every call to ``get_db()`` will return the same " "connection, and it will be closed automatically at the end of the " "request." -msgstr "" -"在请求当中,所有调用 ``get_db()`` 的地方均会返回一样的连接,而这个连接会在请" -"求结束的时候自动关闭。" +msgstr "在请求当中,所有调用 ``get_db()`` 的地方均会返回一样的连接,而这个连接会在请求结束的时候自动关闭。" #: ../../appcontext.rst:130 msgid "" "You can use :class:`~werkzeug.local.LocalProxy` to make a new context " "local from ``get_db()``::" -msgstr "" -"通过 :class:`~werkzeug.local.LocalProxy` 可以从 ``get_db()`` 创建一个新的上下" -"文本地变量:" +msgstr "通过 :class:`~werkzeug.local.LocalProxy` 可以从 ``get_db()`` 创建一个新的上下文本地变量:" #: ../../appcontext.rst:136 msgid "" "Accessing ``db`` will call ``get_db`` internally, in the same way that " ":data:`current_app` works." -msgstr "" -"访问 ``db`` 会内部调用 ``get_db``,就像访问 :data:`current_app` 的调用机制一" -"样。" +msgstr "访问 ``db`` 会内部调用 ``get_db``,就像访问 :data:`current_app` 的调用机制一样。" #: ../../appcontext.rst:141 msgid "" @@ -227,10 +207,10 @@ msgid "" ":data:`_app_ctx_stack.top <_app_ctx_stack>`. For more information see " ":doc:`/extensiondev`." msgstr "" -"在编写扩展的过程当中,:data:`g` 应该为用户代码保留。扩展的内部数据应该存储在上下文" -"对象的属性当中,除此以外还要保证使用一个足够独特的属性名称。当前的上下文" -"可以通过 :data:`_app_ctx_stack.top <_app_ctx_stack>` 获取。" -"更多信息参见 :doc:`/extensiondev`。" +"在编写扩展的过程当中,:data:`g` " +"应该为用户代码保留。扩展的内部数据应该存储在上下文对象的属性当中,除此以外还要保证使用一个足够独特的属性名称。当前的上下文可以通过 " +":data:`_app_ctx_stack.top <_app_ctx_stack>` 获取。更多信息参见 " +":doc:`/extensiondev`。" #: ../../appcontext.rst:149 msgid "Events and Signals" @@ -241,9 +221,7 @@ msgid "" "The application will call functions registered with " ":meth:`~Flask.teardown_appcontext` when the application context is " "popped." -msgstr "" -"在应用上下文被弹出的时候,应用会调用注册在 :meth:`~Flask." -"teardown_appcontext` 的函数。" +msgstr "在应用上下文被弹出的时候,应用会调用注册在 :meth:`~Flask.teardown_appcontext` 的函数。" #: ../../appcontext.rst:155 msgid "" @@ -251,6 +229,6 @@ msgid "" "sent: :data:`appcontext_pushed`, :data:`appcontext_tearing_down`, and " ":data:`appcontext_popped`." msgstr "" -"如果 :data:`~signals.signals_available` 为真,下列信号将被发送::data:" -"`appcontext_pushed`、:data:`appcontext_tearing_down`、以及 :data:" -"`appcontext_popped`." +"如果 :data:`~signals.signals_available` " +"为真,下列信号将被发送::data:`appcontext_pushed`、:data:`appcontext_tearing_down`、以及 " +":data:`appcontext_popped`." diff --git a/docs/locales/zh_CN/LC_MESSAGES/async-await.po b/docs/locales/zh_CN/LC_MESSAGES/async-await.po index fccc7c159..73600adaa 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/async-await.po +++ b/docs/locales/zh_CN/LC_MESSAGES/async-await.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-30 19:27+0000\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: zh_CN \n" @@ -31,21 +31,31 @@ msgid "" msgstr "" #: ../../async-await.rst:21 +msgid "" +"Pluggable class-based views also support handlers that are implemented as" +" coroutines. This applies to the " +":meth:`~flask.views.View.dispatch_request` method in views that inherit " +"from the :class:`flask.views.View` class, as well as all the HTTP method " +"handlers in views that inherit from the :class:`flask.views.MethodView` " +"class." +msgstr "" + +#: ../../async-await.rst:27 msgid "Using ``async`` on Windows on Python 3.8" msgstr "" -#: ../../async-await.rst:23 +#: ../../async-await.rst:29 msgid "" "Python 3.8 has a bug related to asyncio on Windows. If you encounter " "something like ``ValueError: set_wakeup_fd only works in main thread``, " "please upgrade to Python 3.9." msgstr "" -#: ../../async-await.rst:29 +#: ../../async-await.rst:35 msgid "Performance" msgstr "" -#: ../../async-await.rst:31 +#: ../../async-await.rst:37 msgid "" "Async functions require an event loop to run. Flask, as a WSGI " "application, uses one worker to handle one request/response cycle. When a" @@ -53,7 +63,7 @@ msgid "" "thread, run the view function there, then return the result." msgstr "" -#: ../../async-await.rst:36 +#: ../../async-await.rst:42 msgid "" "Each request still ties up one worker, even for async views. The upside " "is that you can run async code within a view, for example to make " @@ -62,7 +72,7 @@ msgid "" "time will remain the same." msgstr "" -#: ../../async-await.rst:42 +#: ../../async-await.rst:48 msgid "" "**Async is not inherently faster than sync code.** Async is beneficial " "when performing concurrent IO-bound tasks, but will probably not improve " @@ -71,11 +81,11 @@ msgid "" "that wasn't possible natively before." msgstr "" -#: ../../async-await.rst:50 +#: ../../async-await.rst:56 msgid "Background tasks" msgstr "" -#: ../../async-await.rst:52 +#: ../../async-await.rst:58 msgid "" "Async functions will run in an event loop until they complete, at which " "stage the event loop will stop. This means any additional spawned tasks " @@ -84,7 +94,7 @@ msgid "" "``asyncio.create_task``." msgstr "" -#: ../../async-await.rst:58 +#: ../../async-await.rst:64 msgid "" "If you wish to use background tasks it is best to use a task queue to " "trigger background work, rather than spawn tasks in a view function. With" @@ -94,11 +104,11 @@ msgid "" "continually." msgstr "" -#: ../../async-await.rst:67 +#: ../../async-await.rst:73 msgid "When to use Quart instead" msgstr "" -#: ../../async-await.rst:69 +#: ../../async-await.rst:75 msgid "" "Flask's async support is less performant than async-first frameworks due " "to the way it is implemented. If you have a mainly async codebase it " @@ -108,7 +118,7 @@ msgid "" "without requiring multiple worker processes or threads." msgstr "" -#: ../../async-await.rst:76 +#: ../../async-await.rst:82 msgid "" "It has also already been possible to run Flask with Gevent or Eventlet to" " get many of the benefits of async request handling. These libraries " @@ -118,11 +128,11 @@ msgid "" "to understanding the specific needs of your project." msgstr "" -#: ../../async-await.rst:88 +#: ../../async-await.rst:94 msgid "Extensions" msgstr "" -#: ../../async-await.rst:90 +#: ../../async-await.rst:96 msgid "" "Flask extensions predating Flask's async support do not expect async " "views. If they provide decorators to add functionality to views, those " @@ -132,7 +142,7 @@ msgid "" "view." msgstr "" -#: ../../async-await.rst:96 +#: ../../async-await.rst:102 msgid "" "Extension authors can support async functions by utilising the " ":meth:`flask.Flask.ensure_sync` method. For example, if the extension " @@ -140,17 +150,17 @@ msgid "" " decorated function," msgstr "" -#: ../../async-await.rst:111 +#: ../../async-await.rst:117 msgid "" "Check the changelog of the extension you want to use to see if they've " "implemented async support, or make a feature request or PR to them." msgstr "" -#: ../../async-await.rst:116 +#: ../../async-await.rst:122 msgid "Other event loops" msgstr "" -#: ../../async-await.rst:118 +#: ../../async-await.rst:124 msgid "" "At the moment Flask only supports :mod:`asyncio`. It's possible to " "override :meth:`flask.Flask.ensure_sync` to change how async functions " diff --git a/docs/locales/zh_CN/LC_MESSAGES/changes.po b/docs/locales/zh_CN/LC_MESSAGES/changes.po index 40827a78f..b7009e569 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/changes.po +++ b/docs/locales/zh_CN/LC_MESSAGES/changes.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-30 19:27+0000\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: zh_CN \n" @@ -22,114 +22,188 @@ msgid "Changes" msgstr "" #: ../../../CHANGES.rst:4 -msgid "Version 2.1.0" +msgid "Version 2.0.3" msgstr "" -#: ../../../CHANGES.rst:6 ../../../CHANGES.rst:14 -msgid "Unreleased" +#: ../../../CHANGES.rst:6 +msgid "Released 2022-02-14" msgstr "" #: ../../../CHANGES.rst:8 -msgid "Update Click dependency to >= 8.0." +msgid "" +"The test client's ``as_tuple`` parameter is deprecated and will be " +"removed in Werkzeug 2.1. It is now also deprecated in Flask, to be " +"removed in Flask 2.1, while remaining compatible with both in 2.0.x. Use " +"``response.request.environ`` instead. :pr:`4341`" msgstr "" #: ../../../CHANGES.rst:12 +msgid "Fix type annotation for ``errorhandler`` decorator. :issue:`4295`" +msgstr "" + +#: ../../../CHANGES.rst:13 +msgid "" +"Revert a change to the CLI that caused it to hide ``ImportError`` " +"tracebacks when importing the application. :issue:`4307`" +msgstr "" + +#: ../../../CHANGES.rst:15 +msgid "" +"``app.json_encoder`` and ``json_decoder`` are only passed to ``dumps`` " +"and ``loads`` if they have custom behavior. This improves performance, " +"mainly on PyPy. :issue:`4349`" +msgstr "" + +#: ../../../CHANGES.rst:18 +msgid "" +"Clearer error message when ``after_this_request`` is used outside a " +"request context. :issue:`4333`" +msgstr "" + +#: ../../../CHANGES.rst:23 msgid "Version 2.0.2" msgstr "" -#: ../../../CHANGES.rst:16 -msgid "Fix type annotation for ``teardown_request``. :issue:`4093`" +#: ../../../CHANGES.rst:25 +msgid "Released 2021-10-04" msgstr "" -#: ../../../CHANGES.rst:17 +#: ../../../CHANGES.rst:27 +msgid "Fix type annotation for ``teardown_*`` methods. :issue:`4093`" +msgstr "" + +#: ../../../CHANGES.rst:28 msgid "" "Fix type annotation for ``before_request`` and ``before_app_request`` " "decorators. :issue:`4104`" msgstr "" -#: ../../../CHANGES.rst:19 +#: ../../../CHANGES.rst:30 msgid "" "Fixed the issue where typing requires template global decorators to " "accept functions with no arguments. :issue:`4098`" msgstr "" -#: ../../../CHANGES.rst:24 +#: ../../../CHANGES.rst:32 +msgid "Support View and MethodView instances with async handlers. :issue:`4112`" +msgstr "" + +#: ../../../CHANGES.rst:33 +msgid "Enhance typing of ``app.errorhandler`` decorator. :issue:`4095`" +msgstr "" + +#: ../../../CHANGES.rst:34 +msgid "Fix registering a blueprint twice with differing names. :issue:`4124`" +msgstr "" + +#: ../../../CHANGES.rst:35 +msgid "" +"Fix the type of ``static_folder`` to accept ``pathlib.Path``. " +":issue:`4150`" +msgstr "" + +#: ../../../CHANGES.rst:37 +msgid "" +"``jsonify`` handles ``decimal.Decimal`` by encoding to ``str``. " +":issue:`4157`" +msgstr "" + +#: ../../../CHANGES.rst:39 +msgid "" +"Correctly handle raising deferred errors in CLI lazy loading. " +":issue:`4096`" +msgstr "" + +#: ../../../CHANGES.rst:41 +msgid "" +"The CLI loader handles ``**kwargs`` in a ``create_app`` function. " +":issue:`4170`" +msgstr "" + +#: ../../../CHANGES.rst:43 +msgid "" +"Fix the order of ``before_request`` and other callbacks that trigger " +"before the view returns. They are called from the app down to the closest" +" nested blueprint. :issue:`4229`" +msgstr "" + +#: ../../../CHANGES.rst:49 msgid "Version 2.0.1" msgstr "" -#: ../../../CHANGES.rst:26 +#: ../../../CHANGES.rst:51 msgid "Released 2021-05-21" msgstr "" -#: ../../../CHANGES.rst:28 +#: ../../../CHANGES.rst:53 msgid "" "Re-add the ``filename`` parameter in ``send_from_directory``. The " "``filename`` parameter has been renamed to ``path``, the old name is " "deprecated. :pr:`4019`" msgstr "" -#: ../../../CHANGES.rst:31 +#: ../../../CHANGES.rst:56 msgid "" "Mark top-level names as exported so type checking understands imports in " "user projects. :issue:`4024`" msgstr "" -#: ../../../CHANGES.rst:33 +#: ../../../CHANGES.rst:58 msgid "" "Fix type annotation for ``g`` and inform mypy that it is a namespace " "object that has arbitrary attributes. :issue:`4020`" msgstr "" -#: ../../../CHANGES.rst:35 +#: ../../../CHANGES.rst:60 msgid "Fix some types that weren't available in Python 3.6.0. :issue:`4040`" msgstr "" -#: ../../../CHANGES.rst:36 +#: ../../../CHANGES.rst:61 msgid "" "Improve typing for ``send_file``, ``send_from_directory``, and " "``get_send_file_max_age``. :issue:`4044`, :pr:`4026`" msgstr "" -#: ../../../CHANGES.rst:38 +#: ../../../CHANGES.rst:63 msgid "" "Show an error when a blueprint name contains a dot. The ``.`` has special" " meaning, it is used to separate (nested) blueprint names and the " "endpoint name. :issue:`4041`" msgstr "" -#: ../../../CHANGES.rst:41 +#: ../../../CHANGES.rst:66 msgid "" "Combine URL prefixes when nesting blueprints that were created with a " "``url_prefix`` value. :issue:`4037`" msgstr "" -#: ../../../CHANGES.rst:43 +#: ../../../CHANGES.rst:68 msgid "" "Roll back a change to the order that URL matching was done. The URL is " "again matched after the session is loaded, so the session is available in" " custom URL converters. :issue:`4053`" msgstr "" -#: ../../../CHANGES.rst:46 +#: ../../../CHANGES.rst:71 msgid "" "Re-add deprecated ``Config.from_json``, which was accidentally removed " "early. :issue:`4078`" msgstr "" -#: ../../../CHANGES.rst:48 +#: ../../../CHANGES.rst:73 msgid "" "Improve typing for some functions using ``Callable`` in their type " "signatures, focusing on decorator factories. :issue:`4060`" msgstr "" -#: ../../../CHANGES.rst:50 +#: ../../../CHANGES.rst:75 msgid "" "Nested blueprints are registered with their dotted name. This allows " "different blueprints with the same name to be nested at different " "locations. :issue:`4069`" msgstr "" -#: ../../../CHANGES.rst:53 +#: ../../../CHANGES.rst:78 msgid "" "``register_blueprint`` takes a ``name`` option to change the (pre-dotted)" " name the blueprint is registered with. This allows the same blueprint to" @@ -138,23 +212,23 @@ msgid "" "deprecated. :issue:`1091`" msgstr "" -#: ../../../CHANGES.rst:58 +#: ../../../CHANGES.rst:83 msgid "Improve typing for ``stream_with_context``. :issue:`4052`" msgstr "" -#: ../../../CHANGES.rst:62 +#: ../../../CHANGES.rst:87 msgid "Version 2.0.0" msgstr "" -#: ../../../CHANGES.rst:64 +#: ../../../CHANGES.rst:89 msgid "Released 2021-05-11" msgstr "" -#: ../../../CHANGES.rst:66 +#: ../../../CHANGES.rst:91 msgid "Drop support for Python 2 and 3.5." msgstr "" -#: ../../../CHANGES.rst:67 +#: ../../../CHANGES.rst:92 msgid "" "Bump minimum versions of other Pallets projects: Werkzeug >= 2, Jinja2 >=" " 3, MarkupSafe >= 2, ItsDangerous >= 2, Click >= 8. Be sure to check the " @@ -164,75 +238,75 @@ msgid "" "DeprecationWarning and Flask 2.1 will depend on Click 8." msgstr "" -#: ../../../CHANGES.rst:73 +#: ../../../CHANGES.rst:98 msgid "" "JSON support no longer uses simplejson. To use another JSON module, " "override ``app.json_encoder`` and ``json_decoder``. :issue:`3555`" msgstr "" -#: ../../../CHANGES.rst:75 +#: ../../../CHANGES.rst:100 msgid "The ``encoding`` option to JSON functions is deprecated. :pr:`3562`" msgstr "" -#: ../../../CHANGES.rst:76 +#: ../../../CHANGES.rst:101 msgid "" "Passing ``script_info`` to app factory functions is deprecated. This was " "not portable outside the ``flask`` command. Use " "``click.get_current_context().obj`` if it's needed. :issue:`3552`" msgstr "" -#: ../../../CHANGES.rst:79 +#: ../../../CHANGES.rst:104 msgid "" "The CLI shows better error messages when the app failed to load when " "looking up commands. :issue:`2741`" msgstr "" -#: ../../../CHANGES.rst:81 +#: ../../../CHANGES.rst:106 msgid "" "Add :meth:`sessions.SessionInterface.get_cookie_name` to allow setting " "the session cookie name dynamically. :pr:`3369`" msgstr "" -#: ../../../CHANGES.rst:83 +#: ../../../CHANGES.rst:108 msgid "" "Add :meth:`Config.from_file` to load config using arbitrary file loaders," " such as ``toml.load`` or ``json.load``. :meth:`Config.from_json` is " "deprecated in favor of this. :pr:`3398`" msgstr "" -#: ../../../CHANGES.rst:86 +#: ../../../CHANGES.rst:111 msgid "" "The ``flask run`` command will only defer errors on reload. Errors " "present during the initial call will cause the server to exit with the " "traceback immediately. :issue:`3431`" msgstr "" -#: ../../../CHANGES.rst:89 +#: ../../../CHANGES.rst:114 msgid "" ":func:`send_file` raises a :exc:`ValueError` when passed an :mod:`io` " "object in text mode. Previously, it would respond with 200 OK and an " "empty file. :issue:`3358`" msgstr "" -#: ../../../CHANGES.rst:92 +#: ../../../CHANGES.rst:117 msgid "" "When using ad-hoc certificates, check for the cryptography library " "instead of PyOpenSSL. :pr:`3492`" msgstr "" -#: ../../../CHANGES.rst:94 +#: ../../../CHANGES.rst:119 msgid "" "When specifying a factory function with ``FLASK_APP``, keyword argument " "can be passed. :issue:`3553`" msgstr "" -#: ../../../CHANGES.rst:96 +#: ../../../CHANGES.rst:121 msgid "" "When loading a ``.env`` or ``.flaskenv`` file, the current working " "directory is no longer changed to the location of the file. :pr:`3560`" msgstr "" -#: ../../../CHANGES.rst:99 +#: ../../../CHANGES.rst:124 msgid "" "When returning a ``(response, headers)`` tuple from a view, the headers " "replace rather than extend existing headers on the response. For example," @@ -240,7 +314,7 @@ msgid "" "``response.headers.extend()`` if extending is desired. :issue:`3628`" msgstr "" -#: ../../../CHANGES.rst:104 +#: ../../../CHANGES.rst:129 msgid "" "The ``Scaffold`` class provides a common API for the ``Flask`` and " "``Blueprint`` classes. ``Blueprint`` information is stored in attributes " @@ -248,23 +322,23 @@ msgid "" "intended to improve consistency and maintainability. :issue:`3215`" msgstr "" -#: ../../../CHANGES.rst:109 +#: ../../../CHANGES.rst:134 msgid "" "Include ``samesite`` and ``secure`` options when removing the session " "cookie. :pr:`3726`" msgstr "" -#: ../../../CHANGES.rst:111 +#: ../../../CHANGES.rst:136 msgid "Support passing a ``pathlib.Path`` to ``static_folder``. :pr:`3579`" msgstr "" -#: ../../../CHANGES.rst:112 +#: ../../../CHANGES.rst:137 msgid "" "``send_file`` and ``send_from_directory`` are wrappers around the " "implementations in ``werkzeug.utils``. :pr:`3828`" msgstr "" -#: ../../../CHANGES.rst:114 +#: ../../../CHANGES.rst:139 msgid "" "Some ``send_file`` parameters have been renamed, the old names are " "deprecated. ``attachment_filename`` is renamed to ``download_name``. " @@ -272,13 +346,13 @@ msgid "" "``etag``. :pr:`3828, 3883`" msgstr "" -#: ../../../CHANGES.rst:118 +#: ../../../CHANGES.rst:143 msgid "" "``send_file`` passes ``download_name`` even if ``as_attachment=False`` by" " using ``Content-Disposition: inline``. :pr:`3828`" msgstr "" -#: ../../../CHANGES.rst:121 +#: ../../../CHANGES.rst:146 msgid "" "``send_file`` sets ``conditional=True`` and ``max_age=None`` by default. " "``Cache-Control`` is set to ``no-cache`` if ``max_age`` is not set, " @@ -286,144 +360,144 @@ msgid "" "requests instead of using a timed cache. :pr:`3828`" msgstr "" -#: ../../../CHANGES.rst:125 +#: ../../../CHANGES.rst:150 msgid "" "``helpers.safe_join`` is deprecated. Use ``werkzeug.utils.safe_join`` " "instead. :pr:`3828`" msgstr "" -#: ../../../CHANGES.rst:127 +#: ../../../CHANGES.rst:152 msgid "" "The request context does route matching before opening the session. This " "could allow a session interface to change behavior based on " "``request.endpoint``. :issue:`3776`" msgstr "" -#: ../../../CHANGES.rst:130 +#: ../../../CHANGES.rst:155 msgid "Use Jinja's implementation of the ``|tojson`` filter. :issue:`3881`" msgstr "" -#: ../../../CHANGES.rst:131 +#: ../../../CHANGES.rst:156 msgid "" "Add route decorators for common HTTP methods. For example, " "``@app.post(\"/login\")`` is a shortcut for ``@app.route(\"/login\", " "methods=[\"POST\"])``. :pr:`3907`" msgstr "" -#: ../../../CHANGES.rst:134 +#: ../../../CHANGES.rst:159 msgid "" "Support async views, error handlers, before and after request, and " "teardown functions. :pr:`3412`" msgstr "" -#: ../../../CHANGES.rst:136 +#: ../../../CHANGES.rst:161 msgid "Support nesting blueprints. :issue:`593, 1548`, :pr:`3923`" msgstr "" -#: ../../../CHANGES.rst:137 +#: ../../../CHANGES.rst:162 msgid "" "Set the default encoding to \"UTF-8\" when loading ``.env`` and " "``.flaskenv`` files to allow to use non-ASCII characters. :issue:`3931`" msgstr "" -#: ../../../CHANGES.rst:139 +#: ../../../CHANGES.rst:164 msgid "" "``flask shell`` sets up tab and history completion like the default " "``python`` shell if ``readline`` is installed. :issue:`3941`" msgstr "" -#: ../../../CHANGES.rst:141 +#: ../../../CHANGES.rst:166 msgid "" "``helpers.total_seconds()`` is deprecated. Use " "``timedelta.total_seconds()`` instead. :pr:`3962`" msgstr "" -#: ../../../CHANGES.rst:143 +#: ../../../CHANGES.rst:168 msgid "Add type hinting. :pr:`3973`." msgstr "" -#: ../../../CHANGES.rst:147 +#: ../../../CHANGES.rst:172 msgid "Version 1.1.4" msgstr "" -#: ../../../CHANGES.rst:149 ../../../CHANGES.rst:158 +#: ../../../CHANGES.rst:174 ../../../CHANGES.rst:183 msgid "Released 2021-05-13" msgstr "" -#: ../../../CHANGES.rst:151 +#: ../../../CHANGES.rst:176 msgid "" "Update ``static_folder`` to use ``_compat.fspath`` instead of " "``os.fspath`` to continue supporting Python < 3.6 :issue:`4050`" msgstr "" -#: ../../../CHANGES.rst:156 +#: ../../../CHANGES.rst:181 msgid "Version 1.1.3" msgstr "" -#: ../../../CHANGES.rst:160 +#: ../../../CHANGES.rst:185 msgid "" "Set maximum versions of Werkzeug, Jinja, Click, and ItsDangerous. " ":issue:`4043`" msgstr "" -#: ../../../CHANGES.rst:162 +#: ../../../CHANGES.rst:187 msgid "" "Re-add support for passing a ``pathlib.Path`` for ``static_folder``. " ":pr:`3579`" msgstr "" -#: ../../../CHANGES.rst:167 +#: ../../../CHANGES.rst:192 msgid "Version 1.1.2" msgstr "" -#: ../../../CHANGES.rst:169 +#: ../../../CHANGES.rst:194 msgid "Released 2020-04-03" msgstr "" -#: ../../../CHANGES.rst:171 +#: ../../../CHANGES.rst:196 msgid "" "Work around an issue when running the ``flask`` command with an external " "debugger on Windows. :issue:`3297`" msgstr "" -#: ../../../CHANGES.rst:173 +#: ../../../CHANGES.rst:198 msgid "" "The static route will not catch all URLs if the ``Flask`` " "``static_folder`` argument ends with a slash. :issue:`3452`" msgstr "" -#: ../../../CHANGES.rst:178 +#: ../../../CHANGES.rst:203 msgid "Version 1.1.1" msgstr "" -#: ../../../CHANGES.rst:180 +#: ../../../CHANGES.rst:205 msgid "Released 2019-07-08" msgstr "" -#: ../../../CHANGES.rst:182 +#: ../../../CHANGES.rst:207 msgid "" "The ``flask.json_available`` flag was added back for compatibility with " "some extensions. It will raise a deprecation warning when used, and will " "be removed in version 2.0.0. :issue:`3288`" msgstr "" -#: ../../../CHANGES.rst:188 +#: ../../../CHANGES.rst:213 msgid "Version 1.1.0" msgstr "" -#: ../../../CHANGES.rst:190 ../../../CHANGES.rst:280 +#: ../../../CHANGES.rst:215 ../../../CHANGES.rst:305 msgid "Released 2019-07-04" msgstr "" -#: ../../../CHANGES.rst:192 +#: ../../../CHANGES.rst:217 msgid "Bump minimum Werkzeug version to >= 0.15." msgstr "" -#: ../../../CHANGES.rst:193 +#: ../../../CHANGES.rst:218 msgid "Drop support for Python 3.4." msgstr "" -#: ../../../CHANGES.rst:194 +#: ../../../CHANGES.rst:219 msgid "" "Error handlers for ``InternalServerError`` or ``500`` will always be " "passed an instance of ``InternalServerError``. If they are invoked due to" @@ -434,13 +508,13 @@ msgid "" ":pr:`3266`" msgstr "" -#: ../../../CHANGES.rst:202 +#: ../../../CHANGES.rst:227 msgid "" ":meth:`Flask.finalize_request` is called for all unhandled exceptions " "even if there is no ``500`` error handler." msgstr "" -#: ../../../CHANGES.rst:205 +#: ../../../CHANGES.rst:230 msgid "" ":attr:`Flask.logger` takes the same name as :attr:`Flask.name` (the value" " passed as ``Flask(import_name)``. This reverts 1.0's behavior of always " @@ -449,114 +523,114 @@ msgid "" "that needs to be moved. :issue:`2866`" msgstr "" -#: ../../../CHANGES.rst:211 +#: ../../../CHANGES.rst:236 msgid "" ":meth:`flask.RequestContext.copy` includes the current session object in " "the request context copy. This prevents ``session`` pointing to an out-" "of-date object. :issue:`2935`" msgstr "" -#: ../../../CHANGES.rst:214 +#: ../../../CHANGES.rst:239 msgid "" "Using built-in RequestContext, unprintable Unicode characters in Host " "header will result in a HTTP 400 response and not HTTP 500 as previously." " :pr:`2994`" msgstr "" -#: ../../../CHANGES.rst:217 +#: ../../../CHANGES.rst:242 msgid "" ":func:`send_file` supports :class:`~os.PathLike` objects as described in " "PEP 0519, to support :mod:`pathlib` in Python 3. :pr:`3059`" msgstr "" -#: ../../../CHANGES.rst:220 +#: ../../../CHANGES.rst:245 msgid "" ":func:`send_file` supports :class:`~io.BytesIO` partial content. " ":issue:`2957`" msgstr "" -#: ../../../CHANGES.rst:222 +#: ../../../CHANGES.rst:247 msgid "" ":func:`open_resource` accepts the \"rt\" file mode. This still does the " "same thing as \"r\". :issue:`3163`" msgstr "" -#: ../../../CHANGES.rst:224 +#: ../../../CHANGES.rst:249 msgid "" "The :attr:`MethodView.methods` attribute set in a base class is used by " "subclasses. :issue:`3138`" msgstr "" -#: ../../../CHANGES.rst:226 +#: ../../../CHANGES.rst:251 msgid "" ":attr:`Flask.jinja_options` is a ``dict`` instead of an ``ImmutableDict``" " to allow easier configuration. Changes must still be made before " "creating the environment. :pr:`3190`" msgstr "" -#: ../../../CHANGES.rst:229 +#: ../../../CHANGES.rst:254 msgid "" "Flask's ``JSONMixin`` for the request and response wrappers was moved " "into Werkzeug. Use Werkzeug's version with Flask-specific support. This " "bumps the Werkzeug dependency to >= 0.15. :issue:`3125`" msgstr "" -#: ../../../CHANGES.rst:233 +#: ../../../CHANGES.rst:258 msgid "" "The ``flask`` command entry point is simplified to take advantage of " "Werkzeug 0.15's better reloader support. This bumps the Werkzeug " "dependency to >= 0.15. :issue:`3022`" msgstr "" -#: ../../../CHANGES.rst:236 +#: ../../../CHANGES.rst:261 msgid "Support ``static_url_path`` that ends with a forward slash. :issue:`3134`" msgstr "" -#: ../../../CHANGES.rst:238 +#: ../../../CHANGES.rst:263 msgid "" "Support empty ``static_folder`` without requiring setting an empty " "``static_url_path`` as well. :pr:`3124`" msgstr "" -#: ../../../CHANGES.rst:240 +#: ../../../CHANGES.rst:265 msgid "" ":meth:`jsonify` supports :class:`dataclasses.dataclass` objects. " ":pr:`3195`" msgstr "" -#: ../../../CHANGES.rst:242 +#: ../../../CHANGES.rst:267 msgid "" "Allow customizing the :attr:`Flask.url_map_class` used for routing. " ":pr:`3069`" msgstr "" -#: ../../../CHANGES.rst:244 +#: ../../../CHANGES.rst:269 msgid "" "The development server port can be set to 0, which tells the OS to pick " "an available port. :issue:`2926`" msgstr "" -#: ../../../CHANGES.rst:246 +#: ../../../CHANGES.rst:271 msgid "" "The return value from :meth:`cli.load_dotenv` is more consistent with the" " documentation. It will return ``False`` if python-dotenv is not " "installed, or if the given path isn't a file. :issue:`2937`" msgstr "" -#: ../../../CHANGES.rst:249 +#: ../../../CHANGES.rst:274 msgid "" "Signaling support has a stub for the ``connect_via`` method when the " "Blinker library is not installed. :pr:`3208`" msgstr "" -#: ../../../CHANGES.rst:251 +#: ../../../CHANGES.rst:276 msgid "" "Add an ``--extra-files`` option to the ``flask run`` CLI command to " "specify extra files that will trigger the reloader on change. " ":issue:`2897`" msgstr "" -#: ../../../CHANGES.rst:254 +#: ../../../CHANGES.rst:279 msgid "" "Allow returning a dictionary from a view function. Similar to how " "returning a string will produce a ``text/html`` response, returning a " @@ -564,40 +638,40 @@ msgid "" ":pr:`3111`" msgstr "" -#: ../../../CHANGES.rst:258 +#: ../../../CHANGES.rst:283 msgid "" "Blueprints have a ``cli`` Click group like ``app.cli``. CLI commands " "registered with a blueprint will be available as a group under the " "``flask`` command. :issue:`1357`." msgstr "" -#: ../../../CHANGES.rst:261 +#: ../../../CHANGES.rst:286 msgid "" "When using the test client as a context manager (``with client:``), all " "preserved request contexts are popped when the block exits, ensuring " "nested contexts are cleaned up correctly. :pr:`3157`" msgstr "" -#: ../../../CHANGES.rst:264 +#: ../../../CHANGES.rst:289 msgid "" "Show a better error message when the view return type is not supported. " ":issue:`3214`" msgstr "" -#: ../../../CHANGES.rst:266 +#: ../../../CHANGES.rst:291 msgid "" "``flask.testing.make_test_environ_builder()`` has been deprecated in " "favour of a new class ``flask.testing.EnvironBuilder``. :pr:`3232`" msgstr "" -#: ../../../CHANGES.rst:268 +#: ../../../CHANGES.rst:293 msgid "" "The ``flask run`` command no longer fails if Python is not built with SSL" " support. Using the ``--cert`` option will show an appropriate error " "message. :issue:`3211`" msgstr "" -#: ../../../CHANGES.rst:271 +#: ../../../CHANGES.rst:296 msgid "" "URL matching now occurs after the request context is pushed, rather than " "when it's created. This allows custom URL converters to access the app " @@ -605,65 +679,65 @@ msgid "" ":issue:`3088`" msgstr "" -#: ../../../CHANGES.rst:278 +#: ../../../CHANGES.rst:303 msgid "Version 1.0.4" msgstr "" -#: ../../../CHANGES.rst:282 +#: ../../../CHANGES.rst:307 msgid "" "The key information for ``BadRequestKeyError`` is no longer cleared " "outside debug mode, so error handlers can still access it. This requires " "upgrading to Werkzeug 0.15.5. :issue:`3249`" msgstr "" -#: ../../../CHANGES.rst:285 +#: ../../../CHANGES.rst:310 msgid "" "``send_file`` url quotes the \":\" and \"/\" characters for more " "compatible UTF-8 filename support in some browsers. :issue:`3074`" msgstr "" -#: ../../../CHANGES.rst:287 +#: ../../../CHANGES.rst:312 msgid "Fixes for PEP451 import loaders and pytest 5.x. :issue:`3275`" msgstr "" -#: ../../../CHANGES.rst:288 +#: ../../../CHANGES.rst:313 msgid "Show message about dotenv on stderr instead of stdout. :issue:`3285`" msgstr "" -#: ../../../CHANGES.rst:292 +#: ../../../CHANGES.rst:317 msgid "Version 1.0.3" msgstr "" -#: ../../../CHANGES.rst:294 +#: ../../../CHANGES.rst:319 msgid "Released 2019-05-17" msgstr "" -#: ../../../CHANGES.rst:296 +#: ../../../CHANGES.rst:321 msgid "" ":func:`send_file` encodes filenames as ASCII instead of Latin-1 " "(ISO-8859-1). This fixes compatibility with Gunicorn, which is stricter " "about header encodings than PEP 3333. :issue:`2766`" msgstr "" -#: ../../../CHANGES.rst:299 +#: ../../../CHANGES.rst:324 msgid "" "Allow custom CLIs using ``FlaskGroup`` to set the debug flag without it " "always being overwritten based on environment variables. :pr:`2765`" msgstr "" -#: ../../../CHANGES.rst:302 +#: ../../../CHANGES.rst:327 msgid "" "``flask --version`` outputs Werkzeug's version and simplifies the Python " "version. :pr:`2825`" msgstr "" -#: ../../../CHANGES.rst:304 +#: ../../../CHANGES.rst:329 msgid "" ":func:`send_file` handles an ``attachment_filename`` that is a native " "Python 2 string (bytes) with UTF-8 coded bytes. :issue:`2933`" msgstr "" -#: ../../../CHANGES.rst:306 +#: ../../../CHANGES.rst:331 msgid "" "A catch-all error handler registered for ``HTTPException`` will not " "handle ``RoutingException``, which is used internally during routing. " @@ -671,188 +745,188 @@ msgid "" ":pr:`2986`" msgstr "" -#: ../../../CHANGES.rst:310 +#: ../../../CHANGES.rst:335 msgid "" "Passing the ``json`` argument to ``app.test_client`` does not push/pop an" " extra app context. :issue:`2900`" msgstr "" -#: ../../../CHANGES.rst:315 +#: ../../../CHANGES.rst:340 msgid "Version 1.0.2" msgstr "" -#: ../../../CHANGES.rst:317 +#: ../../../CHANGES.rst:342 msgid "Released 2018-05-02" msgstr "" -#: ../../../CHANGES.rst:319 +#: ../../../CHANGES.rst:344 msgid "" "Fix more backwards compatibility issues with merging slashes between a " "blueprint prefix and route. :pr:`2748`" msgstr "" -#: ../../../CHANGES.rst:321 +#: ../../../CHANGES.rst:346 msgid "" "Fix error with ``flask routes`` command when there are no routes. " ":issue:`2751`" msgstr "" -#: ../../../CHANGES.rst:326 +#: ../../../CHANGES.rst:351 msgid "Version 1.0.1" msgstr "" -#: ../../../CHANGES.rst:328 ../../../CHANGES.rst:516 +#: ../../../CHANGES.rst:353 ../../../CHANGES.rst:541 msgid "Released 2018-04-29" msgstr "" -#: ../../../CHANGES.rst:330 +#: ../../../CHANGES.rst:355 msgid "" "Fix registering partials (with no ``__name__``) as view functions. " ":pr:`2730`" msgstr "" -#: ../../../CHANGES.rst:332 +#: ../../../CHANGES.rst:357 msgid "" "Don't treat lists returned from view functions the same as tuples. Only " "tuples are interpreted as response data. :issue:`2736`" msgstr "" -#: ../../../CHANGES.rst:334 +#: ../../../CHANGES.rst:359 msgid "" "Extra slashes between a blueprint's ``url_prefix`` and a route URL are " "merged. This fixes some backwards compatibility issues with the change in" " 1.0. :issue:`2731`, :issue:`2742`" msgstr "" -#: ../../../CHANGES.rst:337 +#: ../../../CHANGES.rst:362 msgid "" "Only trap ``BadRequestKeyError`` errors in debug mode, not all " "``BadRequest`` errors. This allows ``abort(400)`` to continue working as " "expected. :issue:`2735`" msgstr "" -#: ../../../CHANGES.rst:340 +#: ../../../CHANGES.rst:365 msgid "" "The ``FLASK_SKIP_DOTENV`` environment variable can be set to ``1`` to " "skip automatically loading dotenv files. :issue:`2722`" msgstr "" -#: ../../../CHANGES.rst:345 +#: ../../../CHANGES.rst:370 msgid "Version 1.0" msgstr "" -#: ../../../CHANGES.rst:347 ../../../CHANGES.rst:524 +#: ../../../CHANGES.rst:372 ../../../CHANGES.rst:549 msgid "Released 2018-04-26" msgstr "" -#: ../../../CHANGES.rst:349 +#: ../../../CHANGES.rst:374 msgid "Python 2.6 and 3.3 are no longer supported." msgstr "" -#: ../../../CHANGES.rst:350 +#: ../../../CHANGES.rst:375 msgid "" "Bump minimum dependency versions to the latest stable versions: Werkzeug " ">= 0.14, Jinja >= 2.10, itsdangerous >= 0.24, Click >= 5.1. :issue:`2586`" msgstr "" -#: ../../../CHANGES.rst:353 +#: ../../../CHANGES.rst:378 msgid "" "Skip :meth:`app.run ` when a Flask application is run from the" " command line. This avoids some behavior that was confusing to debug." msgstr "" -#: ../../../CHANGES.rst:356 +#: ../../../CHANGES.rst:381 msgid "" "Change the default for :data:`JSONIFY_PRETTYPRINT_REGULAR` to ``False``. " ":func:`~json.jsonify` returns a compact format by default, and an " "indented format in debug mode. :pr:`2193`" msgstr "" -#: ../../../CHANGES.rst:359 +#: ../../../CHANGES.rst:384 msgid "" ":meth:`Flask.__init__ ` accepts the ``host_matching`` argument and" " sets it on :attr:`~Flask.url_map`. :issue:`1559`" msgstr "" -#: ../../../CHANGES.rst:361 +#: ../../../CHANGES.rst:386 msgid "" ":meth:`Flask.__init__ ` accepts the ``static_host`` argument and " "passes it as the ``host`` argument when defining the static route. " ":issue:`1559`" msgstr "" -#: ../../../CHANGES.rst:364 +#: ../../../CHANGES.rst:389 msgid ":func:`send_file` supports Unicode in ``attachment_filename``. :pr:`2223`" msgstr "" -#: ../../../CHANGES.rst:366 +#: ../../../CHANGES.rst:391 msgid "" "Pass ``_scheme`` argument from :func:`url_for` to " ":meth:`~Flask.handle_url_build_error`. :pr:`2017`" msgstr "" -#: ../../../CHANGES.rst:368 +#: ../../../CHANGES.rst:393 msgid "" ":meth:`~Flask.add_url_rule` accepts the ``provide_automatic_options`` " "argument to disable adding the ``OPTIONS`` method. :pr:`1489`" msgstr "" -#: ../../../CHANGES.rst:371 +#: ../../../CHANGES.rst:396 msgid "" ":class:`~views.MethodView` subclasses inherit method handlers from base " "classes. :pr:`1936`" msgstr "" -#: ../../../CHANGES.rst:373 +#: ../../../CHANGES.rst:398 msgid "" "Errors caused while opening the session at the beginning of the request " "are handled by the app's error handlers. :pr:`2254`" msgstr "" -#: ../../../CHANGES.rst:375 +#: ../../../CHANGES.rst:400 msgid "" "Blueprints gained :attr:`~Blueprint.json_encoder` and " ":attr:`~Blueprint.json_decoder` attributes to override the app's encoder " "and decoder. :pr:`1898`" msgstr "" -#: ../../../CHANGES.rst:378 +#: ../../../CHANGES.rst:403 msgid "" ":meth:`Flask.make_response` raises ``TypeError`` instead of " "``ValueError`` for bad response types. The error messages have been " "improved to describe why the type is invalid. :pr:`2256`" msgstr "" -#: ../../../CHANGES.rst:381 +#: ../../../CHANGES.rst:406 msgid "" "Add ``routes`` CLI command to output routes registered on the " "application. :pr:`2259`" msgstr "" -#: ../../../CHANGES.rst:383 +#: ../../../CHANGES.rst:408 msgid "" "Show warning when session cookie domain is a bare hostname or an IP " "address, as these may not behave properly in some browsers, such as " "Chrome. :pr:`2282`" msgstr "" -#: ../../../CHANGES.rst:386 +#: ../../../CHANGES.rst:411 msgid "Allow IP address as exact session cookie domain. :pr:`2282`" msgstr "" -#: ../../../CHANGES.rst:387 +#: ../../../CHANGES.rst:412 msgid "" "``SESSION_COOKIE_DOMAIN`` is set if it is detected through " "``SERVER_NAME``. :pr:`2282`" msgstr "" -#: ../../../CHANGES.rst:389 +#: ../../../CHANGES.rst:414 msgid "" "Auto-detect zero-argument app factory called ``create_app`` or " "``make_app`` from ``FLASK_APP``. :pr:`2297`" msgstr "" -#: ../../../CHANGES.rst:391 +#: ../../../CHANGES.rst:416 msgid "" "Factory functions are not required to take a ``script_info`` parameter to" " work with the ``flask`` command. If they take a single parameter or a " @@ -860,19 +934,19 @@ msgid "" " be passed. :pr:`2319`" msgstr "" -#: ../../../CHANGES.rst:395 +#: ../../../CHANGES.rst:420 msgid "" "``FLASK_APP`` can be set to an app factory, with arguments if needed, for" " example ``FLASK_APP=myproject.app:create_app('dev')``. :pr:`2326`" msgstr "" -#: ../../../CHANGES.rst:398 +#: ../../../CHANGES.rst:423 msgid "" "``FLASK_APP`` can point to local packages that are not installed in " "editable mode, although ``pip install -e`` is still preferred. :pr:`2414`" msgstr "" -#: ../../../CHANGES.rst:401 +#: ../../../CHANGES.rst:426 msgid "" "The :class:`~views.View` class attribute " ":attr:`~views.View.provide_automatic_options` is set in " @@ -880,58 +954,58 @@ msgid "" ":meth:`~Flask.add_url_rule`. :pr:`2316`" msgstr "" -#: ../../../CHANGES.rst:405 +#: ../../../CHANGES.rst:430 msgid "" "Error handling will try handlers registered for ``blueprint, code``, " "``app, code``, ``blueprint, exception``, ``app, exception``. :pr:`2314`" msgstr "" -#: ../../../CHANGES.rst:408 +#: ../../../CHANGES.rst:433 msgid "" "``Cookie`` is added to the response's ``Vary`` header if the session is " "accessed at all during the request (and not deleted). :pr:`2288`" msgstr "" -#: ../../../CHANGES.rst:410 +#: ../../../CHANGES.rst:435 msgid "" ":meth:`~Flask.test_request_context` accepts ``subdomain`` and " "``url_scheme`` arguments for use when building the base URL. :pr:`1621`" msgstr "" -#: ../../../CHANGES.rst:413 +#: ../../../CHANGES.rst:438 msgid "" "Set :data:`APPLICATION_ROOT` to ``'/'`` by default. This was already the " "implicit default when it was set to ``None``." msgstr "" -#: ../../../CHANGES.rst:415 +#: ../../../CHANGES.rst:440 msgid "" ":data:`TRAP_BAD_REQUEST_ERRORS` is enabled by default in debug mode. " "``BadRequestKeyError`` has a message with the bad key in debug mode " "instead of the generic bad request message. :pr:`2348`" msgstr "" -#: ../../../CHANGES.rst:418 +#: ../../../CHANGES.rst:443 msgid "" "Allow registering new tags with :class:`~json.tag.TaggedJSONSerializer` " "to support storing other types in the session cookie. :pr:`2352`" msgstr "" -#: ../../../CHANGES.rst:421 +#: ../../../CHANGES.rst:446 msgid "" "Only open the session if the request has not been pushed onto the context" " stack yet. This allows :func:`~stream_with_context` generators to access" " the same session that the containing view uses. :pr:`2354`" msgstr "" -#: ../../../CHANGES.rst:425 +#: ../../../CHANGES.rst:450 msgid "" "Add ``json`` keyword argument for the test client request methods. This " "will dump the given object as JSON and set the appropriate content type. " ":pr:`2358`" msgstr "" -#: ../../../CHANGES.rst:428 +#: ../../../CHANGES.rst:453 msgid "" "Extract JSON handling to a mixin applied to both the :class:`Request` and" " :class:`Response` classes. This adds the :meth:`~Response.is_json` and " @@ -939,84 +1013,84 @@ msgid "" "response much easier. :pr:`2358`" msgstr "" -#: ../../../CHANGES.rst:432 +#: ../../../CHANGES.rst:457 msgid "" "Removed error handler caching because it caused unexpected results for " "some exception inheritance hierarchies. Register handlers explicitly for " "each exception if you want to avoid traversing the MRO. :pr:`2362`" msgstr "" -#: ../../../CHANGES.rst:436 +#: ../../../CHANGES.rst:461 msgid "Fix incorrect JSON encoding of aware, non-UTC datetimes. :pr:`2374`" msgstr "" -#: ../../../CHANGES.rst:437 +#: ../../../CHANGES.rst:462 msgid "" "Template auto reloading will honor debug mode even even if " ":attr:`~Flask.jinja_env` was already accessed. :pr:`2373`" msgstr "" -#: ../../../CHANGES.rst:439 +#: ../../../CHANGES.rst:464 msgid "The following old deprecated code was removed. :issue:`2385`" msgstr "" -#: ../../../CHANGES.rst:441 +#: ../../../CHANGES.rst:466 msgid "" "``flask.ext`` - import extensions directly by their name instead of " "through the ``flask.ext`` namespace. For example, ``import " "flask.ext.sqlalchemy`` becomes ``import flask_sqlalchemy``." msgstr "" -#: ../../../CHANGES.rst:445 +#: ../../../CHANGES.rst:470 msgid "" "``Flask.init_jinja_globals`` - extend " ":meth:`Flask.create_jinja_environment` instead." msgstr "" -#: ../../../CHANGES.rst:447 +#: ../../../CHANGES.rst:472 msgid "" "``Flask.error_handlers`` - tracked by :attr:`Flask.error_handler_spec`, " "use :meth:`Flask.errorhandler` to register handlers." msgstr "" -#: ../../../CHANGES.rst:450 +#: ../../../CHANGES.rst:475 msgid "" "``Flask.request_globals_class`` - use :attr:`Flask.app_ctx_globals_class`" " instead." msgstr "" -#: ../../../CHANGES.rst:452 +#: ../../../CHANGES.rst:477 msgid "``Flask.static_path`` - use :attr:`Flask.static_url_path` instead." msgstr "" -#: ../../../CHANGES.rst:454 +#: ../../../CHANGES.rst:479 msgid "``Request.module`` - use :attr:`Request.blueprint` instead." msgstr "" -#: ../../../CHANGES.rst:456 +#: ../../../CHANGES.rst:481 msgid "The :attr:`Request.json` property is no longer deprecated. :issue:`1421`" msgstr "" -#: ../../../CHANGES.rst:458 +#: ../../../CHANGES.rst:483 msgid "" "Support passing a :class:`~werkzeug.test.EnvironBuilder` or ``dict`` to " ":meth:`test_client.open `. :pr:`2412`" msgstr "" -#: ../../../CHANGES.rst:460 +#: ../../../CHANGES.rst:485 msgid "" "The ``flask`` command and :meth:`Flask.run` will load environment " "variables from ``.env`` and ``.flaskenv`` files if python-dotenv is " "installed. :pr:`2416`" msgstr "" -#: ../../../CHANGES.rst:463 +#: ../../../CHANGES.rst:488 msgid "" "When passing a full URL to the test client, the scheme in the URL is used" " instead of :data:`PREFERRED_URL_SCHEME`. :pr:`2430`" msgstr "" -#: ../../../CHANGES.rst:465 +#: ../../../CHANGES.rst:490 msgid "" ":attr:`Flask.logger` has been simplified. ``LOGGER_NAME`` and " "``LOGGER_HANDLER_POLICY`` config was removed. The logger is always named " @@ -1026,275 +1100,275 @@ msgid "" "handler is only added if no handlers are already configured. :pr:`2436`" msgstr "" -#: ../../../CHANGES.rst:472 +#: ../../../CHANGES.rst:497 msgid "Blueprint view function names may not contain dots. :pr:`2450`" msgstr "" -#: ../../../CHANGES.rst:473 +#: ../../../CHANGES.rst:498 msgid "" "Fix a ``ValueError`` caused by invalid ``Range`` requests in some cases. " ":issue:`2526`" msgstr "" -#: ../../../CHANGES.rst:475 +#: ../../../CHANGES.rst:500 msgid "The development server uses threads by default. :pr:`2529`" msgstr "" -#: ../../../CHANGES.rst:476 +#: ../../../CHANGES.rst:501 msgid "" "Loading config files with ``silent=True`` will ignore " ":data:`~errno.ENOTDIR` errors. :pr:`2581`" msgstr "" -#: ../../../CHANGES.rst:478 +#: ../../../CHANGES.rst:503 msgid "" "Pass ``--cert`` and ``--key`` options to ``flask run`` to run the " "development server over HTTPS. :pr:`2606`" msgstr "" -#: ../../../CHANGES.rst:480 +#: ../../../CHANGES.rst:505 msgid "" "Added :data:`SESSION_COOKIE_SAMESITE` to control the ``SameSite`` " "attribute on the session cookie. :pr:`2607`" msgstr "" -#: ../../../CHANGES.rst:482 +#: ../../../CHANGES.rst:507 msgid "" "Added :meth:`~flask.Flask.test_cli_runner` to create a Click runner that " "can invoke Flask CLI commands for testing. :pr:`2636`" msgstr "" -#: ../../../CHANGES.rst:484 +#: ../../../CHANGES.rst:509 msgid "" "Subdomain matching is disabled by default and setting :data:`SERVER_NAME`" " does not implicitly enable it. It can be enabled by passing " "``subdomain_matching=True`` to the ``Flask`` constructor. :pr:`2635`" msgstr "" -#: ../../../CHANGES.rst:488 +#: ../../../CHANGES.rst:513 msgid "" "A single trailing slash is stripped from the blueprint ``url_prefix`` " "when it is registered with the app. :pr:`2629`" msgstr "" -#: ../../../CHANGES.rst:490 +#: ../../../CHANGES.rst:515 msgid "" ":meth:`Request.get_json` doesn't cache the result if parsing fails when " "``silent`` is true. :issue:`2651`" msgstr "" -#: ../../../CHANGES.rst:492 +#: ../../../CHANGES.rst:517 msgid "" ":func:`Request.get_json` no longer accepts arbitrary encodings. Incoming " "JSON should be encoded using UTF-8 per :rfc:`8259`, but Flask will " "autodetect UTF-8, -16, or -32. :pr:`2691`" msgstr "" -#: ../../../CHANGES.rst:495 +#: ../../../CHANGES.rst:520 msgid "" "Added :data:`MAX_COOKIE_SIZE` and :attr:`Response.max_cookie_size` to " "control when Werkzeug warns about large cookies that browsers may ignore." " :pr:`2693`" msgstr "" -#: ../../../CHANGES.rst:498 +#: ../../../CHANGES.rst:523 msgid "" "Updated documentation theme to make docs look better in small windows. " ":pr:`2709`" msgstr "" -#: ../../../CHANGES.rst:500 +#: ../../../CHANGES.rst:525 msgid "" "Rewrote the tutorial docs and example project to take a more structured " "approach to help new users avoid common pitfalls. :pr:`2676`" msgstr "" -#: ../../../CHANGES.rst:506 +#: ../../../CHANGES.rst:531 msgid "Version 0.12.5" msgstr "" -#: ../../../CHANGES.rst:508 +#: ../../../CHANGES.rst:533 msgid "Released 2020-02-10" msgstr "" -#: ../../../CHANGES.rst:510 +#: ../../../CHANGES.rst:535 msgid "Pin Werkzeug to < 1.0.0. :issue:`3497`" msgstr "" -#: ../../../CHANGES.rst:514 +#: ../../../CHANGES.rst:539 msgid "Version 0.12.4" msgstr "" -#: ../../../CHANGES.rst:518 +#: ../../../CHANGES.rst:543 msgid "Repackage 0.12.3 to fix package layout issue. :issue:`2728`" msgstr "" -#: ../../../CHANGES.rst:522 +#: ../../../CHANGES.rst:547 msgid "Version 0.12.3" msgstr "" -#: ../../../CHANGES.rst:526 +#: ../../../CHANGES.rst:551 msgid "" ":func:`Request.get_json` no longer accepts arbitrary encodings. Incoming " "JSON should be encoded using UTF-8 per :rfc:`8259`, but Flask will " "autodetect UTF-8, -16, or -32. :issue:`2692`" msgstr "" -#: ../../../CHANGES.rst:529 +#: ../../../CHANGES.rst:554 msgid "" "Fix a Python warning about imports when using ``python -m flask``. " ":issue:`2666`" msgstr "" -#: ../../../CHANGES.rst:531 +#: ../../../CHANGES.rst:556 msgid "Fix a ``ValueError`` caused by invalid ``Range`` requests in some cases." msgstr "" -#: ../../../CHANGES.rst:536 +#: ../../../CHANGES.rst:561 msgid "Version 0.12.2" msgstr "" -#: ../../../CHANGES.rst:538 +#: ../../../CHANGES.rst:563 msgid "Released 2017-05-16" msgstr "" -#: ../../../CHANGES.rst:540 +#: ../../../CHANGES.rst:565 msgid "Fix a bug in ``safe_join`` on Windows." msgstr "" -#: ../../../CHANGES.rst:544 +#: ../../../CHANGES.rst:569 msgid "Version 0.12.1" msgstr "" -#: ../../../CHANGES.rst:546 +#: ../../../CHANGES.rst:571 msgid "Released 2017-03-31" msgstr "" -#: ../../../CHANGES.rst:548 +#: ../../../CHANGES.rst:573 msgid "" "Prevent ``flask run`` from showing a ``NoAppException`` when an " "``ImportError`` occurs within the imported application module." msgstr "" -#: ../../../CHANGES.rst:550 +#: ../../../CHANGES.rst:575 msgid "" "Fix encoding behavior of ``app.config.from_pyfile`` for Python 3. " ":issue:`2118`" msgstr "" -#: ../../../CHANGES.rst:552 +#: ../../../CHANGES.rst:577 msgid "" "Use the ``SERVER_NAME`` config if it is present as default values for " "``app.run``. :issue:`2109`, :pr:`2152`" msgstr "" -#: ../../../CHANGES.rst:554 +#: ../../../CHANGES.rst:579 msgid "" "Call ``ctx.auto_pop`` with the exception object instead of ``None``, in " "the event that a ``BaseException`` such as ``KeyboardInterrupt`` is " "raised in a request handler." msgstr "" -#: ../../../CHANGES.rst:560 +#: ../../../CHANGES.rst:585 msgid "Version 0.12" msgstr "" -#: ../../../CHANGES.rst:562 +#: ../../../CHANGES.rst:587 msgid "Released 2016-12-21, codename Punsch" msgstr "" -#: ../../../CHANGES.rst:564 +#: ../../../CHANGES.rst:589 msgid "The cli command now responds to ``--version``." msgstr "" -#: ../../../CHANGES.rst:565 +#: ../../../CHANGES.rst:590 msgid "" "Mimetype guessing and ETag generation for file-like objects in " "``send_file`` has been removed. :issue:`104`, :pr`1849`" msgstr "" -#: ../../../CHANGES.rst:567 +#: ../../../CHANGES.rst:592 msgid "" "Mimetype guessing in ``send_file`` now fails loudly and doesn't fall back" " to ``application/octet-stream``. :pr:`1988`" msgstr "" -#: ../../../CHANGES.rst:569 +#: ../../../CHANGES.rst:594 msgid "" "Make ``flask.safe_join`` able to join multiple paths like " "``os.path.join`` :pr:`1730`" msgstr "" -#: ../../../CHANGES.rst:571 +#: ../../../CHANGES.rst:596 msgid "" "Revert a behavior change that made the dev server crash instead of " "returning an Internal Server Error. :pr:`2006`" msgstr "" -#: ../../../CHANGES.rst:573 +#: ../../../CHANGES.rst:598 msgid "" "Correctly invoke response handlers for both regular request dispatching " "as well as error handlers." msgstr "" -#: ../../../CHANGES.rst:575 +#: ../../../CHANGES.rst:600 msgid "Disable logger propagation by default for the app logger." msgstr "" -#: ../../../CHANGES.rst:576 +#: ../../../CHANGES.rst:601 msgid "Add support for range requests in ``send_file``." msgstr "" -#: ../../../CHANGES.rst:577 +#: ../../../CHANGES.rst:602 msgid "" "``app.test_client`` includes preset default environment, which can now be" " directly set, instead of per ``client.get``." msgstr "" -#: ../../../CHANGES.rst:579 +#: ../../../CHANGES.rst:604 msgid "Fix crash when running under PyPy3. :pr:`1814`" msgstr "" -#: ../../../CHANGES.rst:583 +#: ../../../CHANGES.rst:608 msgid "Version 0.11.1" msgstr "" -#: ../../../CHANGES.rst:585 +#: ../../../CHANGES.rst:610 msgid "Released 2016-06-07" msgstr "" -#: ../../../CHANGES.rst:587 +#: ../../../CHANGES.rst:612 msgid "" "Fixed a bug that prevented ``FLASK_APP=foobar/__init__.py`` from working." " :pr:`1872`" msgstr "" -#: ../../../CHANGES.rst:592 +#: ../../../CHANGES.rst:617 msgid "Version 0.11" msgstr "" -#: ../../../CHANGES.rst:594 +#: ../../../CHANGES.rst:619 msgid "Released 2016-05-29, codename Absinthe" msgstr "" -#: ../../../CHANGES.rst:596 +#: ../../../CHANGES.rst:621 msgid "" "Added support to serializing top-level arrays to :func:`flask.jsonify`. " "This introduces a security risk in ancient browsers." msgstr "" -#: ../../../CHANGES.rst:599 +#: ../../../CHANGES.rst:624 msgid "Added before_render_template signal." msgstr "" -#: ../../../CHANGES.rst:600 +#: ../../../CHANGES.rst:625 msgid "" "Added ``**kwargs`` to :meth:`flask.Test.test_client` to support passing " "additional keyword arguments to the constructor of " ":attr:`flask.Flask.test_client_class`." msgstr "" -#: ../../../CHANGES.rst:603 +#: ../../../CHANGES.rst:628 msgid "" "Added ``SESSION_REFRESH_EACH_REQUEST`` config key that controls the set-" "cookie behavior. If set to ``True`` a permanent session will be refreshed" @@ -1304,45 +1378,45 @@ msgid "" "window closes." msgstr "" -#: ../../../CHANGES.rst:609 +#: ../../../CHANGES.rst:634 msgid "Made Flask support custom JSON mimetypes for incoming data." msgstr "" -#: ../../../CHANGES.rst:610 +#: ../../../CHANGES.rst:635 msgid "" "Added support for returning tuples in the form ``(response, headers)`` " "from a view function." msgstr "" -#: ../../../CHANGES.rst:612 +#: ../../../CHANGES.rst:637 msgid "Added :meth:`flask.Config.from_json`." msgstr "" -#: ../../../CHANGES.rst:613 +#: ../../../CHANGES.rst:638 msgid "Added :attr:`flask.Flask.config_class`." msgstr "" -#: ../../../CHANGES.rst:614 +#: ../../../CHANGES.rst:639 msgid "Added :meth:`flask.Config.get_namespace`." msgstr "" -#: ../../../CHANGES.rst:615 +#: ../../../CHANGES.rst:640 msgid "" "Templates are no longer automatically reloaded outside of debug mode. " "This can be configured with the new ``TEMPLATES_AUTO_RELOAD`` config key." msgstr "" -#: ../../../CHANGES.rst:618 +#: ../../../CHANGES.rst:643 msgid "Added a workaround for a limitation in Python 3.3's namespace loader." msgstr "" -#: ../../../CHANGES.rst:620 +#: ../../../CHANGES.rst:645 msgid "" "Added support for explicit root paths when using Python 3.3's namespace " "packages." msgstr "" -#: ../../../CHANGES.rst:622 +#: ../../../CHANGES.rst:647 msgid "" "Added :command:`flask` and the ``flask.cli`` module to start the local " "debug server through the click CLI system. This is recommended over the " @@ -1350,7 +1424,7 @@ msgid "" "different design and also replaces ``Flask-Script``." msgstr "" -#: ../../../CHANGES.rst:627 +#: ../../../CHANGES.rst:652 msgid "" "Error handlers that match specific classes are now checked first, thereby" " allowing catching exceptions that are subclasses of HTTP exceptions (in " @@ -1359,43 +1433,43 @@ msgid "" "their choosing, but may be caught with a custom error handler if desired." msgstr "" -#: ../../../CHANGES.rst:633 +#: ../../../CHANGES.rst:658 msgid "Added :meth:`flask.Config.from_mapping`." msgstr "" -#: ../../../CHANGES.rst:634 +#: ../../../CHANGES.rst:659 msgid "" "Flask will now log by default even if debug is disabled. The log format " "is now hardcoded but the default log handling can be disabled through the" " ``LOGGER_HANDLER_POLICY`` configuration key." msgstr "" -#: ../../../CHANGES.rst:637 +#: ../../../CHANGES.rst:662 msgid "Removed deprecated module functionality." msgstr "" -#: ../../../CHANGES.rst:638 +#: ../../../CHANGES.rst:663 msgid "" "Added the ``EXPLAIN_TEMPLATE_LOADING`` config flag which when enabled " "will instruct Flask to explain how it locates templates. This should help" " users debug when the wrong templates are loaded." msgstr "" -#: ../../../CHANGES.rst:641 +#: ../../../CHANGES.rst:666 msgid "" "Enforce blueprint handling in the order they were registered for template" " loading." msgstr "" -#: ../../../CHANGES.rst:643 +#: ../../../CHANGES.rst:668 msgid "Ported test suite to py.test." msgstr "" -#: ../../../CHANGES.rst:644 +#: ../../../CHANGES.rst:669 msgid "Deprecated ``request.json`` in favour of ``request.get_json()``." msgstr "" -#: ../../../CHANGES.rst:645 +#: ../../../CHANGES.rst:670 msgid "" "Add \"pretty\" and \"compressed\" separators definitions in jsonify() " "method. Reduces JSON response size when " @@ -1403,7 +1477,7 @@ msgid "" " included by default after separators." msgstr "" -#: ../../../CHANGES.rst:649 +#: ../../../CHANGES.rst:674 msgid "" "JSON responses are now terminated with a newline character, because it is" " a convention that UNIX text files end with a newline and some clients " @@ -1411,120 +1485,120 @@ msgid "" "a part of https://github.com/postmanlabs/httpbin/issues/168. :pr:`1262`" msgstr "" -#: ../../../CHANGES.rst:654 +#: ../../../CHANGES.rst:679 msgid "" "The automatically provided ``OPTIONS`` method is now correctly disabled " "if the user registered an overriding rule with the lowercase-version " "``options``. :issue:`1288`" msgstr "" -#: ../../../CHANGES.rst:657 +#: ../../../CHANGES.rst:682 msgid "``flask.json.jsonify`` now supports the ``datetime.date`` type. :pr:`1326`" msgstr "" -#: ../../../CHANGES.rst:659 +#: ../../../CHANGES.rst:684 msgid "" "Don't leak exception info of already caught exceptions to context " "teardown handlers. :pr:`1393`" msgstr "" -#: ../../../CHANGES.rst:661 +#: ../../../CHANGES.rst:686 msgid "Allow custom Jinja environment subclasses. :pr:`1422`" msgstr "" -#: ../../../CHANGES.rst:662 +#: ../../../CHANGES.rst:687 msgid "Updated extension dev guidelines." msgstr "" -#: ../../../CHANGES.rst:663 +#: ../../../CHANGES.rst:688 msgid "``flask.g`` now has ``pop()`` and ``setdefault`` methods." msgstr "" -#: ../../../CHANGES.rst:664 +#: ../../../CHANGES.rst:689 msgid "" "Turn on autoescape for ``flask.templating.render_template_string`` by " "default. :pr:`1515`" msgstr "" -#: ../../../CHANGES.rst:666 +#: ../../../CHANGES.rst:691 msgid "``flask.ext`` is now deprecated. :pr:`1484`" msgstr "" -#: ../../../CHANGES.rst:667 +#: ../../../CHANGES.rst:692 msgid "" "``send_from_directory`` now raises BadRequest if the filename is invalid " "on the server OS. :pr:`1763`" msgstr "" -#: ../../../CHANGES.rst:669 +#: ../../../CHANGES.rst:694 msgid "Added the ``JSONIFY_MIMETYPE`` configuration variable. :pr:`1728`" msgstr "" -#: ../../../CHANGES.rst:670 +#: ../../../CHANGES.rst:695 msgid "" "Exceptions during teardown handling will no longer leave bad application " "contexts lingering around." msgstr "" -#: ../../../CHANGES.rst:672 +#: ../../../CHANGES.rst:697 msgid "Fixed broken ``test_appcontext_signals()`` test case." msgstr "" -#: ../../../CHANGES.rst:673 +#: ../../../CHANGES.rst:698 msgid "" "Raise an :exc:`AttributeError` in :func:`flask.helpers.find_package` with" " a useful message explaining why it is raised when a PEP 302 import hook " "is used without an ``is_package()`` method." msgstr "" -#: ../../../CHANGES.rst:676 +#: ../../../CHANGES.rst:701 msgid "" "Fixed an issue causing exceptions raised before entering a request or app" " context to be passed to teardown handlers." msgstr "" -#: ../../../CHANGES.rst:678 +#: ../../../CHANGES.rst:703 msgid "" "Fixed an issue with query parameters getting removed from requests in the" " test client when absolute URLs were requested." msgstr "" -#: ../../../CHANGES.rst:680 +#: ../../../CHANGES.rst:705 msgid "Made ``@before_first_request`` into a decorator as intended." msgstr "" -#: ../../../CHANGES.rst:681 +#: ../../../CHANGES.rst:706 msgid "Fixed an etags bug when sending a file streams with a name." msgstr "" -#: ../../../CHANGES.rst:682 +#: ../../../CHANGES.rst:707 msgid "" "Fixed ``send_from_directory`` not expanding to the application root path " "correctly." msgstr "" -#: ../../../CHANGES.rst:684 +#: ../../../CHANGES.rst:709 msgid "" "Changed logic of before first request handlers to flip the flag after " "invoking. This will allow some uses that are potentially dangerous but " "should probably be permitted." msgstr "" -#: ../../../CHANGES.rst:687 +#: ../../../CHANGES.rst:712 msgid "" "Fixed Python 3 bug when a handler from ``app.url_build_error_handlers`` " "reraises the ``BuildError``." msgstr "" -#: ../../../CHANGES.rst:692 +#: ../../../CHANGES.rst:717 msgid "Version 0.10.1" msgstr "" -#: ../../../CHANGES.rst:694 +#: ../../../CHANGES.rst:719 msgid "Released 2013-06-14" msgstr "" -#: ../../../CHANGES.rst:696 +#: ../../../CHANGES.rst:721 msgid "" "Fixed an issue where ``|tojson`` was not quoting single quotes which made" " the filter not work properly in HTML attributes. Now it's possible to " @@ -1532,94 +1606,94 @@ msgid "" "filter with angular.js easier." msgstr "" -#: ../../../CHANGES.rst:700 +#: ../../../CHANGES.rst:725 msgid "" "Added support for byte strings back to the session system. This broke " "compatibility with the common case of people putting binary data for " "token verification into the session." msgstr "" -#: ../../../CHANGES.rst:703 +#: ../../../CHANGES.rst:728 msgid "" "Fixed an issue where registering the same method twice for the same " "endpoint would trigger an exception incorrectly." msgstr "" -#: ../../../CHANGES.rst:708 +#: ../../../CHANGES.rst:733 msgid "Version 0.10" msgstr "" -#: ../../../CHANGES.rst:710 +#: ../../../CHANGES.rst:735 msgid "Released 2013-06-13, codename Limoncello" msgstr "" -#: ../../../CHANGES.rst:712 +#: ../../../CHANGES.rst:737 msgid "" "Changed default cookie serialization format from pickle to JSON to limit " "the impact an attacker can do if the secret key leaks." msgstr "" -#: ../../../CHANGES.rst:714 +#: ../../../CHANGES.rst:739 msgid "" "Added ``template_test`` methods in addition to the already existing " "``template_filter`` method family." msgstr "" -#: ../../../CHANGES.rst:716 +#: ../../../CHANGES.rst:741 msgid "" "Added ``template_global`` methods in addition to the already existing " "``template_filter`` method family." msgstr "" -#: ../../../CHANGES.rst:718 +#: ../../../CHANGES.rst:743 msgid "Set the content-length header for x-sendfile." msgstr "" -#: ../../../CHANGES.rst:719 +#: ../../../CHANGES.rst:744 msgid "``tojson`` filter now does not escape script blocks in HTML5 parsers." msgstr "" -#: ../../../CHANGES.rst:721 +#: ../../../CHANGES.rst:746 msgid "" "``tojson`` used in templates is now safe by default due. This was allowed" " due to the different escaping behavior." msgstr "" -#: ../../../CHANGES.rst:723 +#: ../../../CHANGES.rst:748 msgid "" "Flask will now raise an error if you attempt to register a new function " "on an already used endpoint." msgstr "" -#: ../../../CHANGES.rst:725 +#: ../../../CHANGES.rst:750 msgid "" "Added wrapper module around simplejson and added default serialization of" " datetime objects. This allows much easier customization of how JSON is " "handled by Flask or any Flask extension." msgstr "" -#: ../../../CHANGES.rst:729 +#: ../../../CHANGES.rst:754 msgid "" "Removed deprecated internal ``flask.session`` module alias. Use " "``flask.sessions`` instead to get the session module. This is not to be " "confused with ``flask.session`` the session proxy." msgstr "" -#: ../../../CHANGES.rst:732 +#: ../../../CHANGES.rst:757 msgid "" "Templates can now be rendered without request context. The behavior is " "slightly different as the ``request``, ``session`` and ``g`` objects will" " not be available and blueprint's context processors are not called." msgstr "" -#: ../../../CHANGES.rst:736 +#: ../../../CHANGES.rst:761 msgid "" "The config object is now available to the template as a real global and " "not through a context processor which makes it available even in imported" " templates by default." msgstr "" -#: ../../../CHANGES.rst:739 +#: ../../../CHANGES.rst:764 msgid "" "Added an option to generate non-ascii encoded JSON which should result in" " less bytes being transmitted over the network. It's disabled by default " @@ -1627,32 +1701,32 @@ msgid "" "``flask.json.dumps`` to return bytes by default." msgstr "" -#: ../../../CHANGES.rst:743 +#: ../../../CHANGES.rst:768 msgid "" "``flask.g`` is now stored on the app context instead of the request " "context." msgstr "" -#: ../../../CHANGES.rst:745 +#: ../../../CHANGES.rst:770 msgid "" "``flask.g`` now gained a ``get()`` method for not erroring out on non " "existing items." msgstr "" -#: ../../../CHANGES.rst:747 +#: ../../../CHANGES.rst:772 msgid "" "``flask.g`` now can be used with the ``in`` operator to see what's " "defined and it now is iterable and will yield all attributes stored." msgstr "" -#: ../../../CHANGES.rst:749 +#: ../../../CHANGES.rst:774 msgid "" "``flask.Flask.request_globals_class`` got renamed to " "``flask.Flask.app_ctx_globals_class`` which is a better name to what it " "does since 0.10." msgstr "" -#: ../../../CHANGES.rst:752 +#: ../../../CHANGES.rst:777 msgid "" "``request``, ``session`` and ``g`` are now also added as proxies to the " "template context which makes them available in imported templates. One " @@ -1660,120 +1734,120 @@ msgid "" "might cause caching." msgstr "" -#: ../../../CHANGES.rst:756 +#: ../../../CHANGES.rst:781 msgid "" "Flask will no longer invoke the wrong error handlers if a proxy exception" " is passed through." msgstr "" -#: ../../../CHANGES.rst:758 +#: ../../../CHANGES.rst:783 msgid "" "Added a workaround for chrome's cookies in localhost not working as " "intended with domain names." msgstr "" -#: ../../../CHANGES.rst:760 +#: ../../../CHANGES.rst:785 msgid "" "Changed logic for picking defaults for cookie values from sessions to " "work better with Google Chrome." msgstr "" -#: ../../../CHANGES.rst:762 +#: ../../../CHANGES.rst:787 msgid "Added ``message_flashed`` signal that simplifies flashing testing." msgstr "" -#: ../../../CHANGES.rst:763 +#: ../../../CHANGES.rst:788 msgid "" "Added support for copying of request contexts for better working with " "greenlets." msgstr "" -#: ../../../CHANGES.rst:765 +#: ../../../CHANGES.rst:790 msgid "" "Removed custom JSON HTTP exception subclasses. If you were relying on " "them you can reintroduce them again yourself trivially. Using them " "however is strongly discouraged as the interface was flawed." msgstr "" -#: ../../../CHANGES.rst:768 +#: ../../../CHANGES.rst:793 msgid "" "Python requirements changed: requiring Python 2.6 or 2.7 now to prepare " "for Python 3.3 port." msgstr "" -#: ../../../CHANGES.rst:770 +#: ../../../CHANGES.rst:795 msgid "" "Changed how the teardown system is informed about exceptions. This is now" " more reliable in case something handles an exception halfway through the" " error handling process." msgstr "" -#: ../../../CHANGES.rst:773 +#: ../../../CHANGES.rst:798 msgid "" "Request context preservation in debug mode now keeps the exception " "information around which means that teardown handlers are able to " "distinguish error from success cases." msgstr "" -#: ../../../CHANGES.rst:776 +#: ../../../CHANGES.rst:801 msgid "Added the ``JSONIFY_PRETTYPRINT_REGULAR`` configuration variable." msgstr "" -#: ../../../CHANGES.rst:777 +#: ../../../CHANGES.rst:802 msgid "" "Flask now orders JSON keys by default to not trash HTTP caches due to " "different hash seeds between different workers." msgstr "" -#: ../../../CHANGES.rst:779 +#: ../../../CHANGES.rst:804 msgid "Added ``appcontext_pushed`` and ``appcontext_popped`` signals." msgstr "" -#: ../../../CHANGES.rst:780 +#: ../../../CHANGES.rst:805 msgid "" "The builtin run method now takes the ``SERVER_NAME`` into account when " "picking the default port to run on." msgstr "" -#: ../../../CHANGES.rst:782 +#: ../../../CHANGES.rst:807 msgid "" "Added ``flask.request.get_json()`` as a replacement for the old " "``flask.request.json`` property." msgstr "" -#: ../../../CHANGES.rst:787 +#: ../../../CHANGES.rst:812 msgid "Version 0.9" msgstr "" -#: ../../../CHANGES.rst:789 +#: ../../../CHANGES.rst:814 msgid "Released 2012-07-01, codename Campari" msgstr "" -#: ../../../CHANGES.rst:791 +#: ../../../CHANGES.rst:816 msgid "" "The :func:`flask.Request.on_json_loading_failed` now returns a JSON " "formatted response by default." msgstr "" -#: ../../../CHANGES.rst:793 +#: ../../../CHANGES.rst:818 msgid "" "The :func:`flask.url_for` function now can generate anchors to the " "generated links." msgstr "" -#: ../../../CHANGES.rst:795 +#: ../../../CHANGES.rst:820 msgid "" "The :func:`flask.url_for` function now can also explicitly generate URL " "rules specific to a given HTTP method." msgstr "" -#: ../../../CHANGES.rst:797 +#: ../../../CHANGES.rst:822 msgid "" "Logger now only returns the debug log setting if it was not set " "explicitly." msgstr "" -#: ../../../CHANGES.rst:799 +#: ../../../CHANGES.rst:824 msgid "" "Unregister a circular dependency between the WSGI environment and the " "request object when shutting down the request. This means that environ " @@ -1783,14 +1857,14 @@ msgid "" "circular dependencies themselves." msgstr "" -#: ../../../CHANGES.rst:805 +#: ../../../CHANGES.rst:830 msgid "" "Session is now stored after callbacks so that if the session payload is " "stored in the session you can still modify it in an after request " "callback." msgstr "" -#: ../../../CHANGES.rst:808 +#: ../../../CHANGES.rst:833 msgid "" "The :class:`flask.Flask` class will avoid importing the provided import " "name if it can (the required first parameter), to benefit tools which " @@ -1800,13 +1874,13 @@ msgid "" "prior to Python 2.7." msgstr "" -#: ../../../CHANGES.rst:814 +#: ../../../CHANGES.rst:839 msgid "" "Blueprints now have a decorator to add custom template filters " "application wide, :meth:`flask.Blueprint.app_template_filter`." msgstr "" -#: ../../../CHANGES.rst:816 +#: ../../../CHANGES.rst:841 msgid "" "The Flask and Blueprint classes now have a non-decorator method for " "adding custom template filters application wide, " @@ -1814,14 +1888,14 @@ msgid "" ":meth:`flask.Blueprint.add_app_template_filter`." msgstr "" -#: ../../../CHANGES.rst:820 +#: ../../../CHANGES.rst:845 msgid "" "The :func:`flask.get_flashed_messages` function now allows rendering " "flashed message categories in separate blocks, through a " "``category_filter`` argument." msgstr "" -#: ../../../CHANGES.rst:823 +#: ../../../CHANGES.rst:848 msgid "" "The :meth:`flask.Flask.run` method now accepts ``None`` for ``host`` and " "``port`` arguments, using default values when ``None``. This allows for " @@ -1830,7 +1904,7 @@ msgid "" "proper behavior whether or not a config file is provided." msgstr "" -#: ../../../CHANGES.rst:828 +#: ../../../CHANGES.rst:853 msgid "" "The :meth:`flask.render_template` method now accepts a either an iterable" " of template names or a single template name. Previously, it only " @@ -1838,21 +1912,21 @@ msgid "" " is rendered." msgstr "" -#: ../../../CHANGES.rst:832 +#: ../../../CHANGES.rst:857 msgid "" "Added :meth:`flask.Flask.app_context` which works very similar to the " "request context but only provides access to the current application. This" " also adds support for URL generation without an active request context." msgstr "" -#: ../../../CHANGES.rst:836 +#: ../../../CHANGES.rst:861 msgid "" "View functions can now return a tuple with the first instance being an " "instance of :class:`flask.Response`. This allows for returning " "``jsonify(error=\"error msg\"), 400`` from a view function." msgstr "" -#: ../../../CHANGES.rst:839 +#: ../../../CHANGES.rst:864 msgid "" ":class:`~flask.Flask` and :class:`~flask.Blueprint` now provide a " ":meth:`~flask.Flask.get_send_file_max_age` hook for subclasses to " @@ -1866,113 +1940,113 @@ msgid "" "implementation." msgstr "" -#: ../../../CHANGES.rst:849 +#: ../../../CHANGES.rst:874 msgid "" "Fixed an assumption in sessions implementation which could break message " "flashing on sessions implementations which use external storage." msgstr "" -#: ../../../CHANGES.rst:852 +#: ../../../CHANGES.rst:877 msgid "" "Changed the behavior of tuple return values from functions. They are no " "longer arguments to the response object, they now have a defined meaning." msgstr "" -#: ../../../CHANGES.rst:855 +#: ../../../CHANGES.rst:880 msgid "" "Added :attr:`flask.Flask.request_globals_class` to allow a specific class" " to be used on creation of the :data:`~flask.g` instance of each request." msgstr "" -#: ../../../CHANGES.rst:858 +#: ../../../CHANGES.rst:883 msgid "" "Added ``required_methods`` attribute to view functions to force-add " "methods on registration." msgstr "" -#: ../../../CHANGES.rst:860 +#: ../../../CHANGES.rst:885 msgid "Added :func:`flask.after_this_request`." msgstr "" -#: ../../../CHANGES.rst:861 +#: ../../../CHANGES.rst:886 msgid "" "Added :func:`flask.stream_with_context` and the ability to push contexts " "multiple times without producing unexpected behavior." msgstr "" -#: ../../../CHANGES.rst:866 +#: ../../../CHANGES.rst:891 msgid "Version 0.8.1" msgstr "" -#: ../../../CHANGES.rst:868 +#: ../../../CHANGES.rst:893 msgid "Released 2012-07-01" msgstr "" -#: ../../../CHANGES.rst:870 +#: ../../../CHANGES.rst:895 msgid "" "Fixed an issue with the undocumented ``flask.session`` module to not work" " properly on Python 2.5. It should not be used but did cause some " "problems for package managers." msgstr "" -#: ../../../CHANGES.rst:876 +#: ../../../CHANGES.rst:901 msgid "Version 0.8" msgstr "" -#: ../../../CHANGES.rst:878 +#: ../../../CHANGES.rst:903 msgid "Released 2011-09-29, codename Rakija" msgstr "" -#: ../../../CHANGES.rst:880 +#: ../../../CHANGES.rst:905 msgid "" "Refactored session support into a session interface so that the " "implementation of the sessions can be changed without having to override " "the Flask class." msgstr "" -#: ../../../CHANGES.rst:883 +#: ../../../CHANGES.rst:908 msgid "Empty session cookies are now deleted properly automatically." msgstr "" -#: ../../../CHANGES.rst:884 +#: ../../../CHANGES.rst:909 msgid "" "View functions can now opt out of getting the automatic OPTIONS " "implementation." msgstr "" -#: ../../../CHANGES.rst:886 +#: ../../../CHANGES.rst:911 msgid "" "HTTP exceptions and Bad Request errors can now be trapped so that they " "show up normally in the traceback." msgstr "" -#: ../../../CHANGES.rst:888 +#: ../../../CHANGES.rst:913 msgid "" "Flask in debug mode is now detecting some common problems and tries to " "warn you about them." msgstr "" -#: ../../../CHANGES.rst:890 +#: ../../../CHANGES.rst:915 msgid "" "Flask in debug mode will now complain with an assertion error if a view " "was attached after the first request was handled. This gives earlier " "feedback when users forget to import view code ahead of time." msgstr "" -#: ../../../CHANGES.rst:894 +#: ../../../CHANGES.rst:919 msgid "" "Added the ability to register callbacks that are only triggered once at " "the beginning of the first request. (:meth:`Flask.before_first_request`)" msgstr "" -#: ../../../CHANGES.rst:897 +#: ../../../CHANGES.rst:922 msgid "" "Malformed JSON data will now trigger a bad request HTTP exception instead" " of a value error which usually would result in a 500 internal server " "error if not handled. This is a backwards incompatible change." msgstr "" -#: ../../../CHANGES.rst:901 +#: ../../../CHANGES.rst:926 msgid "" "Applications now not only have a root path where the resources and " "modules are located but also an instance path which is the designated " @@ -1981,52 +2055,52 @@ msgid "" "so it's the perfect place to put configuration files etc." msgstr "" -#: ../../../CHANGES.rst:907 +#: ../../../CHANGES.rst:932 msgid "Added the ``APPLICATION_ROOT`` configuration variable." msgstr "" -#: ../../../CHANGES.rst:908 +#: ../../../CHANGES.rst:933 msgid "" "Implemented :meth:`~flask.testing.TestClient.session_transaction` to " "easily modify sessions from the test environment." msgstr "" -#: ../../../CHANGES.rst:910 +#: ../../../CHANGES.rst:935 msgid "" "Refactored test client internally. The ``APPLICATION_ROOT`` configuration" " variable as well as ``SERVER_NAME`` are now properly used by the test " "client as defaults." msgstr "" -#: ../../../CHANGES.rst:913 +#: ../../../CHANGES.rst:938 msgid "" "Added :attr:`flask.views.View.decorators` to support simpler decorating " "of pluggable (class-based) views." msgstr "" -#: ../../../CHANGES.rst:915 +#: ../../../CHANGES.rst:940 msgid "" "Fixed an issue where the test client if used with the \"with\" statement " "did not trigger the execution of the teardown handlers." msgstr "" -#: ../../../CHANGES.rst:917 +#: ../../../CHANGES.rst:942 msgid "Added finer control over the session cookie parameters." msgstr "" -#: ../../../CHANGES.rst:918 +#: ../../../CHANGES.rst:943 msgid "" "HEAD requests to a method view now automatically dispatch to the ``get`` " "method if no handler was implemented." msgstr "" -#: ../../../CHANGES.rst:920 +#: ../../../CHANGES.rst:945 msgid "" "Implemented the virtual :mod:`flask.ext` package to import extensions " "from." msgstr "" -#: ../../../CHANGES.rst:922 +#: ../../../CHANGES.rst:947 msgid "" "The context preservation on exceptions is now an integral component of " "Flask itself and no longer of the test client. This cleaned up some " @@ -2034,62 +2108,62 @@ msgid "" "unittests." msgstr "" -#: ../../../CHANGES.rst:926 +#: ../../../CHANGES.rst:951 msgid "" "Fixed the Jinja2 environment's ``list_templates`` method not returning " "the correct names when blueprints or modules were involved." msgstr "" -#: ../../../CHANGES.rst:932 +#: ../../../CHANGES.rst:957 msgid "Version 0.7.2" msgstr "" -#: ../../../CHANGES.rst:934 +#: ../../../CHANGES.rst:959 msgid "Released 2011-07-06" msgstr "" -#: ../../../CHANGES.rst:936 +#: ../../../CHANGES.rst:961 msgid "Fixed an issue with URL processors not properly working on blueprints." msgstr "" -#: ../../../CHANGES.rst:941 +#: ../../../CHANGES.rst:966 msgid "Version 0.7.1" msgstr "" -#: ../../../CHANGES.rst:943 +#: ../../../CHANGES.rst:968 msgid "Released 2011-06-29" msgstr "" -#: ../../../CHANGES.rst:945 +#: ../../../CHANGES.rst:970 msgid "Added missing future import that broke 2.5 compatibility." msgstr "" -#: ../../../CHANGES.rst:946 +#: ../../../CHANGES.rst:971 msgid "Fixed an infinite redirect issue with blueprints." msgstr "" -#: ../../../CHANGES.rst:950 +#: ../../../CHANGES.rst:975 msgid "Version 0.7" msgstr "" -#: ../../../CHANGES.rst:952 +#: ../../../CHANGES.rst:977 msgid "Released 2011-06-28, codename Grappa" msgstr "" -#: ../../../CHANGES.rst:954 +#: ../../../CHANGES.rst:979 msgid "" "Added :meth:`~flask.Flask.make_default_options_response` which can be " "used by subclasses to alter the default behavior for ``OPTIONS`` " "responses." msgstr "" -#: ../../../CHANGES.rst:957 +#: ../../../CHANGES.rst:982 msgid "" "Unbound locals now raise a proper :exc:`RuntimeError` instead of an " ":exc:`AttributeError`." msgstr "" -#: ../../../CHANGES.rst:959 +#: ../../../CHANGES.rst:984 msgid "" "Mimetype guessing and etag support based on file objects is now " "deprecated for :func:`flask.send_file` because it was unreliable. Pass " @@ -2097,7 +2171,7 @@ msgid "" "by hand." msgstr "" -#: ../../../CHANGES.rst:963 +#: ../../../CHANGES.rst:988 msgid "" "Static file handling for modules now requires the name of the static " "folder to be supplied explicitly. The previous autodetection was not " @@ -2105,45 +2179,45 @@ msgid "" "behavior will continue to work but issue dependency warnings." msgstr "" -#: ../../../CHANGES.rst:967 +#: ../../../CHANGES.rst:992 msgid "Fixed a problem for Flask to run on jython." msgstr "" -#: ../../../CHANGES.rst:968 +#: ../../../CHANGES.rst:993 msgid "" "Added a ``PROPAGATE_EXCEPTIONS`` configuration variable that can be used " "to flip the setting of exception propagation which previously was linked " "to ``DEBUG`` alone and is now linked to either ``DEBUG`` or ``TESTING``." msgstr "" -#: ../../../CHANGES.rst:972 +#: ../../../CHANGES.rst:997 msgid "" "Flask no longer internally depends on rules being added through the " "``add_url_rule`` function and can now also accept regular werkzeug rules " "added to the url map." msgstr "" -#: ../../../CHANGES.rst:975 +#: ../../../CHANGES.rst:1000 msgid "" "Added an ``endpoint`` method to the flask application object which allows" " one to register a callback to an arbitrary endpoint with a decorator." msgstr "" -#: ../../../CHANGES.rst:978 +#: ../../../CHANGES.rst:1003 msgid "" "Use Last-Modified for static file sending instead of Date which was " "incorrectly introduced in 0.6." msgstr "" -#: ../../../CHANGES.rst:980 +#: ../../../CHANGES.rst:1005 msgid "Added ``create_jinja_loader`` to override the loader creation process." msgstr "" -#: ../../../CHANGES.rst:982 +#: ../../../CHANGES.rst:1007 msgid "Implemented a silent flag for ``config.from_pyfile``." msgstr "" -#: ../../../CHANGES.rst:983 +#: ../../../CHANGES.rst:1008 msgid "" "Added ``teardown_request`` decorator, for functions that should run at " "the end of a request regardless of whether an exception occurred. Also " @@ -2151,38 +2225,38 @@ msgid "" "executed when an exception is raised." msgstr "" -#: ../../../CHANGES.rst:987 +#: ../../../CHANGES.rst:1012 msgid "Implemented :func:`flask.has_request_context`" msgstr "" -#: ../../../CHANGES.rst:988 +#: ../../../CHANGES.rst:1013 msgid "" "Deprecated ``init_jinja_globals``. Override the " ":meth:`~flask.Flask.create_jinja_environment` method instead to achieve " "the same functionality." msgstr "" -#: ../../../CHANGES.rst:991 +#: ../../../CHANGES.rst:1016 msgid "Added :func:`flask.safe_join`" msgstr "" -#: ../../../CHANGES.rst:992 +#: ../../../CHANGES.rst:1017 msgid "" "The automatic JSON request data unpacking now looks at the charset " "mimetype parameter." msgstr "" -#: ../../../CHANGES.rst:994 +#: ../../../CHANGES.rst:1019 msgid "" "Don't modify the session on :func:`flask.get_flashed_messages` if there " "are no messages in the session." msgstr "" -#: ../../../CHANGES.rst:996 +#: ../../../CHANGES.rst:1021 msgid "``before_request`` handlers are now able to abort requests with errors." msgstr "" -#: ../../../CHANGES.rst:998 +#: ../../../CHANGES.rst:1023 msgid "" "It is not possible to define user exception handlers. That way you can " "provide custom error messages from a central hub for certain errors that " @@ -2190,161 +2264,161 @@ msgid "" "errors, timeouts from remote resources etc.)." msgstr "" -#: ../../../CHANGES.rst:1002 +#: ../../../CHANGES.rst:1027 msgid "Blueprints can provide blueprint specific error handlers." msgstr "" -#: ../../../CHANGES.rst:1003 +#: ../../../CHANGES.rst:1028 msgid "Implemented generic class-based views." msgstr "" -#: ../../../CHANGES.rst:1007 +#: ../../../CHANGES.rst:1032 msgid "Version 0.6.1" msgstr "" -#: ../../../CHANGES.rst:1009 +#: ../../../CHANGES.rst:1034 msgid "Released 2010-12-31" msgstr "" -#: ../../../CHANGES.rst:1011 +#: ../../../CHANGES.rst:1036 msgid "" "Fixed an issue where the default ``OPTIONS`` response was not exposing " "all valid methods in the ``Allow`` header." msgstr "" -#: ../../../CHANGES.rst:1013 +#: ../../../CHANGES.rst:1038 msgid "" "Jinja2 template loading syntax now allows \"./\" in front of a template " "load path. Previously this caused issues with module setups." msgstr "" -#: ../../../CHANGES.rst:1016 +#: ../../../CHANGES.rst:1041 msgid "" "Fixed an issue where the subdomain setting for modules was ignored for " "the static folder." msgstr "" -#: ../../../CHANGES.rst:1018 +#: ../../../CHANGES.rst:1043 msgid "" "Fixed a security problem that allowed clients to download arbitrary files" " if the host server was a windows based operating system and the client " "uses backslashes to escape the directory the files where exposed from." msgstr "" -#: ../../../CHANGES.rst:1025 +#: ../../../CHANGES.rst:1050 msgid "Version 0.6" msgstr "" -#: ../../../CHANGES.rst:1027 +#: ../../../CHANGES.rst:1052 msgid "Released 2010-07-27, codename Whisky" msgstr "" -#: ../../../CHANGES.rst:1029 +#: ../../../CHANGES.rst:1054 msgid "After request functions are now called in reverse order of registration." msgstr "" -#: ../../../CHANGES.rst:1031 +#: ../../../CHANGES.rst:1056 msgid "" "OPTIONS is now automatically implemented by Flask unless the application " "explicitly adds 'OPTIONS' as method to the URL rule. In this case no " "automatic OPTIONS handling kicks in." msgstr "" -#: ../../../CHANGES.rst:1034 +#: ../../../CHANGES.rst:1059 msgid "" "Static rules are now even in place if there is no static folder for the " "module. This was implemented to aid GAE which will remove the static " "folder if it's part of a mapping in the .yml file." msgstr "" -#: ../../../CHANGES.rst:1037 +#: ../../../CHANGES.rst:1062 msgid "" "The :attr:`~flask.Flask.config` is now available in the templates as " "``config``." msgstr "" -#: ../../../CHANGES.rst:1039 +#: ../../../CHANGES.rst:1064 msgid "" "Context processors will no longer override values passed directly to the " "render function." msgstr "" -#: ../../../CHANGES.rst:1041 +#: ../../../CHANGES.rst:1066 msgid "" "Added the ability to limit the incoming request data with the new " "``MAX_CONTENT_LENGTH`` configuration value." msgstr "" -#: ../../../CHANGES.rst:1043 +#: ../../../CHANGES.rst:1068 msgid "" "The endpoint for the :meth:`flask.Module.add_url_rule` method is now " "optional to be consistent with the function of the same name on the " "application object." msgstr "" -#: ../../../CHANGES.rst:1046 +#: ../../../CHANGES.rst:1071 msgid "" "Added a :func:`flask.make_response` function that simplifies creating " "response object instances in views." msgstr "" -#: ../../../CHANGES.rst:1048 +#: ../../../CHANGES.rst:1073 msgid "" "Added signalling support based on blinker. This feature is currently " "optional and supposed to be used by extensions and applications. If you " "want to use it, make sure to have `blinker`_ installed." msgstr "" -#: ../../../CHANGES.rst:1051 +#: ../../../CHANGES.rst:1076 msgid "" "Refactored the way URL adapters are created. This process is now fully " "customizable with the :meth:`~flask.Flask.create_url_adapter` method." msgstr "" -#: ../../../CHANGES.rst:1054 +#: ../../../CHANGES.rst:1079 msgid "" "Modules can now register for a subdomain instead of just an URL prefix. " "This makes it possible to bind a whole module to a configurable " "subdomain." msgstr "" -#: ../../../CHANGES.rst:1062 +#: ../../../CHANGES.rst:1087 msgid "Version 0.5.2" msgstr "" -#: ../../../CHANGES.rst:1064 +#: ../../../CHANGES.rst:1089 msgid "Released 2010-07-15" msgstr "" -#: ../../../CHANGES.rst:1066 +#: ../../../CHANGES.rst:1091 msgid "" "Fixed another issue with loading templates from directories when modules " "were used." msgstr "" -#: ../../../CHANGES.rst:1071 +#: ../../../CHANGES.rst:1096 msgid "Version 0.5.1" msgstr "" -#: ../../../CHANGES.rst:1073 +#: ../../../CHANGES.rst:1098 msgid "Released 2010-07-06" msgstr "" -#: ../../../CHANGES.rst:1075 +#: ../../../CHANGES.rst:1100 msgid "" "Fixes an issue with template loading from directories when modules where " "used." msgstr "" -#: ../../../CHANGES.rst:1080 +#: ../../../CHANGES.rst:1105 msgid "Version 0.5" msgstr "" -#: ../../../CHANGES.rst:1082 +#: ../../../CHANGES.rst:1107 msgid "Released 2010-07-06, codename Calvados" msgstr "" -#: ../../../CHANGES.rst:1084 +#: ../../../CHANGES.rst:1109 msgid "" "Fixed a bug with subdomains that was caused by the inability to specify " "the server name. The server name can now be set with the ``SERVER_NAME`` " @@ -2352,207 +2426,219 @@ msgid "" "subdomain wide." msgstr "" -#: ../../../CHANGES.rst:1088 +#: ../../../CHANGES.rst:1113 msgid "" "Autoescaping is no longer active for all templates. Instead it is only " "active for ``.html``, ``.htm``, ``.xml`` and ``.xhtml``. Inside templates" " this behavior can be changed with the ``autoescape`` tag." msgstr "" -#: ../../../CHANGES.rst:1091 +#: ../../../CHANGES.rst:1116 msgid "Refactored Flask internally. It now consists of more than a single file." msgstr "" -#: ../../../CHANGES.rst:1093 +#: ../../../CHANGES.rst:1118 msgid "" ":func:`flask.send_file` now emits etags and has the ability to do " "conditional responses builtin." msgstr "" -#: ../../../CHANGES.rst:1095 +#: ../../../CHANGES.rst:1120 msgid "" "(temporarily) dropped support for zipped applications. This was a rarely " "used feature and led to some confusing behavior." msgstr "" -#: ../../../CHANGES.rst:1097 +#: ../../../CHANGES.rst:1122 msgid "Added support for per-package template and static-file directories." msgstr "" -#: ../../../CHANGES.rst:1098 +#: ../../../CHANGES.rst:1123 msgid "" "Removed support for ``create_jinja_loader`` which is no longer used in " "0.5 due to the improved module support." msgstr "" -#: ../../../CHANGES.rst:1100 +#: ../../../CHANGES.rst:1125 msgid "Added a helper function to expose files from any directory." msgstr "" -#: ../../../CHANGES.rst:1104 +#: ../../../CHANGES.rst:1129 msgid "Version 0.4" msgstr "" -#: ../../../CHANGES.rst:1106 +#: ../../../CHANGES.rst:1131 msgid "Released 2010-06-18, codename Rakia" msgstr "" -#: ../../../CHANGES.rst:1108 +#: ../../../CHANGES.rst:1133 msgid "" "Added the ability to register application wide error handlers from " "modules." msgstr "" -#: ../../../CHANGES.rst:1110 +#: ../../../CHANGES.rst:1135 msgid "" ":meth:`~flask.Flask.after_request` handlers are now also invoked if the " "request dies with an exception and an error handling page kicks in." msgstr "" -#: ../../../CHANGES.rst:1113 +#: ../../../CHANGES.rst:1138 msgid "" "Test client has not the ability to preserve the request context for a " "little longer. This can also be used to trigger custom requests that do " "not pop the request stack for testing." msgstr "" -#: ../../../CHANGES.rst:1116 +#: ../../../CHANGES.rst:1141 msgid "" "Because the Python standard library caches loggers, the name of the " "logger is configurable now to better support unittests." msgstr "" -#: ../../../CHANGES.rst:1118 +#: ../../../CHANGES.rst:1143 msgid "Added ``TESTING`` switch that can activate unittesting helpers." msgstr "" -#: ../../../CHANGES.rst:1119 +#: ../../../CHANGES.rst:1144 msgid "The logger switches to ``DEBUG`` mode now if debug is enabled." msgstr "" -#: ../../../CHANGES.rst:1123 +#: ../../../CHANGES.rst:1148 msgid "Version 0.3.1" msgstr "" -#: ../../../CHANGES.rst:1125 +#: ../../../CHANGES.rst:1150 msgid "Released 2010-05-28" msgstr "" -#: ../../../CHANGES.rst:1127 +#: ../../../CHANGES.rst:1152 msgid "Fixed a error reporting bug with :meth:`flask.Config.from_envvar`" msgstr "" -#: ../../../CHANGES.rst:1128 +#: ../../../CHANGES.rst:1153 msgid "Removed some unused code from flask" msgstr "" -#: ../../../CHANGES.rst:1129 +#: ../../../CHANGES.rst:1154 msgid "" "Release does no longer include development leftover files (.git folder " "for themes, built documentation in zip and pdf file and some .pyc files)" msgstr "" -#: ../../../CHANGES.rst:1135 +#: ../../../CHANGES.rst:1160 msgid "Version 0.3" msgstr "" -#: ../../../CHANGES.rst:1137 +#: ../../../CHANGES.rst:1162 msgid "Released 2010-05-28, codename Schnaps" msgstr "" -#: ../../../CHANGES.rst:1139 +#: ../../../CHANGES.rst:1164 msgid "Added support for categories for flashed messages." msgstr "" -#: ../../../CHANGES.rst:1140 +#: ../../../CHANGES.rst:1165 msgid "" "The application now configures a :class:`logging.Handler` and will log " "request handling exceptions to that logger when not in debug mode. This " "makes it possible to receive mails on server errors for example." msgstr "" -#: ../../../CHANGES.rst:1144 +#: ../../../CHANGES.rst:1169 msgid "" "Added support for context binding that does not require the use of the " "with statement for playing in the console." msgstr "" -#: ../../../CHANGES.rst:1146 +#: ../../../CHANGES.rst:1171 msgid "" "The request context is now available within the with statement making it " "possible to further push the request context or pop it." msgstr "" -#: ../../../CHANGES.rst:1148 +#: ../../../CHANGES.rst:1173 msgid "Added support for configurations." msgstr "" -#: ../../../CHANGES.rst:1152 +#: ../../../CHANGES.rst:1177 msgid "Version 0.2" msgstr "" -#: ../../../CHANGES.rst:1154 +#: ../../../CHANGES.rst:1179 msgid "Released 2010-05-12, codename J?germeister" msgstr "" -#: ../../../CHANGES.rst:1156 +#: ../../../CHANGES.rst:1181 msgid "Various bugfixes" msgstr "" -#: ../../../CHANGES.rst:1157 +#: ../../../CHANGES.rst:1182 msgid "Integrated JSON support" msgstr "" -#: ../../../CHANGES.rst:1158 +#: ../../../CHANGES.rst:1183 msgid "Added :func:`~flask.get_template_attribute` helper function." msgstr "" -#: ../../../CHANGES.rst:1159 +#: ../../../CHANGES.rst:1184 msgid ":meth:`~flask.Flask.add_url_rule` can now also register a view function." msgstr "" -#: ../../../CHANGES.rst:1161 +#: ../../../CHANGES.rst:1186 msgid "Refactored internal request dispatching." msgstr "" -#: ../../../CHANGES.rst:1162 +#: ../../../CHANGES.rst:1187 msgid "Server listens on 127.0.0.1 by default now to fix issues with chrome." msgstr "" -#: ../../../CHANGES.rst:1164 +#: ../../../CHANGES.rst:1189 msgid "Added external URL support." msgstr "" -#: ../../../CHANGES.rst:1165 +#: ../../../CHANGES.rst:1190 msgid "Added support for :func:`~flask.send_file`" msgstr "" -#: ../../../CHANGES.rst:1166 +#: ../../../CHANGES.rst:1191 msgid "" "Module support and internal request handling refactoring to better " "support pluggable applications." msgstr "" -#: ../../../CHANGES.rst:1168 +#: ../../../CHANGES.rst:1193 msgid "Sessions can be set to be permanent now on a per-session basis." msgstr "" -#: ../../../CHANGES.rst:1169 +#: ../../../CHANGES.rst:1194 msgid "Better error reporting on missing secret keys." msgstr "" -#: ../../../CHANGES.rst:1170 +#: ../../../CHANGES.rst:1195 msgid "Added support for Google Appengine." msgstr "" -#: ../../../CHANGES.rst:1174 +#: ../../../CHANGES.rst:1199 msgid "Version 0.1" msgstr "" -#: ../../../CHANGES.rst:1176 +#: ../../../CHANGES.rst:1201 msgid "Released 2010-04-16" msgstr "" -#: ../../../CHANGES.rst:1178 +#: ../../../CHANGES.rst:1203 msgid "First public preview release." msgstr "" + +#~ msgid "Version 2.1.0" +#~ msgstr "" + +#~ msgid "Unreleased" +#~ msgstr "" + +#~ msgid "Update Click dependency to >= 8.0." +#~ msgstr "" + +#~ msgid "Fix type annotation for ``teardown_request``. :issue:`4093`" +#~ msgstr "" diff --git a/docs/locales/zh_CN/LC_MESSAGES/cli.po b/docs/locales/zh_CN/LC_MESSAGES/cli.po index f6e514911..f47e5e569 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/cli.po +++ b/docs/locales/zh_CN/LC_MESSAGES/cli.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: zh_CN \n" @@ -42,50 +42,55 @@ msgid "" "application." msgstr "" -#: ../../cli.rst:23 ../../cli.rst:141 ../../cli.rst:195 ../../cli.rst:278 -#: ../../cli.rst:326 ../../cli.rst:357 +#: ../../cli.rst:23 ../../cli.rst:153 ../../cli.rst:221 ../../cli.rst:315 +#: ../../cli.rst:371 ../../cli.rst:409 msgid "Bash" msgstr "" -#: ../../cli.rst:30 ../../cli.rst:155 ../../cli.rst:206 ../../cli.rst:286 -#: ../../cli.rst:333 ../../cli.rst:363 +#: ../../cli.rst:30 ../../cli.rst:167 ../../cli.rst:232 ../../cli.rst:323 +#: ../../cli.rst:378 ../../cli.rst:415 +msgid "Fish" +msgstr "" + +#: ../../cli.rst:37 ../../cli.rst:181 ../../cli.rst:243 ../../cli.rst:331 +#: ../../cli.rst:385 ../../cli.rst:421 msgid "CMD" msgstr "" -#: ../../cli.rst:37 ../../cli.rst:169 ../../cli.rst:217 ../../cli.rst:294 -#: ../../cli.rst:340 ../../cli.rst:369 +#: ../../cli.rst:44 ../../cli.rst:195 ../../cli.rst:254 ../../cli.rst:339 +#: ../../cli.rst:392 ../../cli.rst:427 msgid "Powershell" msgstr "" -#: ../../cli.rst:44 +#: ../../cli.rst:51 msgid "" "While ``FLASK_APP`` supports a variety of options for specifying your " "application, most use cases should be simple. Here are the typical " "values:" msgstr "" -#: ../../cli.rst:50 +#: ../../cli.rst:57 msgid "(nothing)" msgstr "" -#: ../../cli.rst:48 +#: ../../cli.rst:55 msgid "" "The name \"app\" or \"wsgi\" is imported (as a \".py\" file, or package)," " automatically detecting an app (``app`` or ``application``) or factory " "(``create_app`` or ``make_app``)." msgstr "" -#: ../../cli.rst:54 +#: ../../cli.rst:61 msgid "``FLASK_APP=hello``" msgstr "" -#: ../../cli.rst:53 +#: ../../cli.rst:60 msgid "" "The given name is imported, automatically detecting an app (``app`` or " "``application``) or factory (``create_app`` or ``make_app``)." msgstr "" -#: ../../cli.rst:58 +#: ../../cli.rst:65 msgid "" "``FLASK_APP`` has three parts: an optional path that sets the current " "working directory, a Python file or dotted import path, and an optional " @@ -94,48 +99,48 @@ msgid "" "values demonstrate these parts:" msgstr "" -#: ../../cli.rst:65 +#: ../../cli.rst:72 msgid "``FLASK_APP=src/hello``" msgstr "" -#: ../../cli.rst:65 +#: ../../cli.rst:72 msgid "Sets the current working directory to ``src`` then imports ``hello``." msgstr "" -#: ../../cli.rst:68 +#: ../../cli.rst:75 msgid "``FLASK_APP=hello.web``" msgstr "" -#: ../../cli.rst:68 +#: ../../cli.rst:75 msgid "Imports the path ``hello.web``." msgstr "" -#: ../../cli.rst:71 +#: ../../cli.rst:78 msgid "``FLASK_APP=hello:app2``" msgstr "" -#: ../../cli.rst:71 +#: ../../cli.rst:78 msgid "Uses the ``app2`` Flask instance in ``hello``." msgstr "" -#: ../../cli.rst:75 +#: ../../cli.rst:82 msgid "``FLASK_APP=\"hello:create_app('dev')\"``" msgstr "" -#: ../../cli.rst:74 +#: ../../cli.rst:81 msgid "" "The ``create_app`` factory in ``hello`` is called with the string " "``'dev'`` as the argument." msgstr "" -#: ../../cli.rst:77 +#: ../../cli.rst:84 msgid "" "If ``FLASK_APP`` is not set, the command will try to import \"app\" or " "\"wsgi\" (as a \".py\" file, or package) and try to detect an application" " instance or factory." msgstr "" -#: ../../cli.rst:81 +#: ../../cli.rst:88 msgid "" "Within the given import, the command looks for an application instance " "named ``app`` or ``application``, then any application instance. If no " @@ -143,24 +148,24 @@ msgid "" "``create_app`` or ``make_app`` that returns an instance." msgstr "" -#: ../../cli.rst:86 +#: ../../cli.rst:93 msgid "" "If parentheses follow the factory name, their contents are parsed as " "Python literals and passed as arguments and keyword arguments to the " "function. This means that strings must still be in quotes." msgstr "" -#: ../../cli.rst:92 +#: ../../cli.rst:99 msgid "Run the Development Server" msgstr "" -#: ../../cli.rst:94 +#: ../../cli.rst:101 msgid "" "The :func:`run ` command will start the development " "server. It replaces the :meth:`Flask.run` method in most cases. ::" msgstr "" -#: ../../cli.rst:101 +#: ../../cli.rst:108 msgid "" "Do not use this command to run your application in production. Only use " "the development server during development. The development server is " @@ -169,11 +174,18 @@ msgid "" "production." msgstr "" -#: ../../cli.rst:108 +#: ../../cli.rst:113 +msgid "" +"If another program is already using port 5000, you'll see ``OSError: " +"[Errno 98]`` or ``OSError: [WinError 10013]`` when the server tries to " +"start. See :ref:`address-already-in-use` for how to handle that." +msgstr "" + +#: ../../cli.rst:120 msgid "Open a Shell" msgstr "" -#: ../../cli.rst:110 +#: ../../cli.rst:122 msgid "" "To explore the data in your application, you can start an interactive " "Python shell with the :func:`shell ` command. An " @@ -181,15 +193,15 @@ msgid "" "imported. ::" msgstr "" -#: ../../cli.rst:121 +#: ../../cli.rst:133 msgid "Use :meth:`~Flask.shell_context_processor` to add other automatic imports." msgstr "" -#: ../../cli.rst:125 +#: ../../cli.rst:137 msgid "Environments" msgstr "" -#: ../../cli.rst:129 +#: ../../cli.rst:141 msgid "" "The environment in which the Flask app runs is set by the " ":envvar:`FLASK_ENV` environment variable. If not set it defaults to " @@ -198,18 +210,18 @@ msgid "" "environment." msgstr "" -#: ../../cli.rst:135 +#: ../../cli.rst:147 msgid "" "If the env is set to ``development``, the ``flask`` command will enable " "debug mode and ``flask run`` will enable the interactive debugger and " "reloader." msgstr "" -#: ../../cli.rst:185 +#: ../../cli.rst:211 msgid "Watch Extra Files with the Reloader" msgstr "" -#: ../../cli.rst:187 +#: ../../cli.rst:213 msgid "" "When using development mode, the reloader will trigger whenever your " "Python code or imported modules change. The reloader can watch additional" @@ -218,29 +230,29 @@ msgid "" "separated with ``:``, or ``;`` on Windows." msgstr "" -#: ../../cli.rst:230 +#: ../../cli.rst:267 msgid "Debug Mode" msgstr "" -#: ../../cli.rst:232 +#: ../../cli.rst:269 msgid "" "Debug mode will be enabled when :envvar:`FLASK_ENV` is ``development``, " "as described above. If you want to control debug mode separately, use " ":envvar:`FLASK_DEBUG`. The value ``1`` enables it, ``0`` disables it." msgstr "" -#: ../../cli.rst:240 +#: ../../cli.rst:277 msgid "Environment Variables From dotenv" msgstr "" -#: ../../cli.rst:242 +#: ../../cli.rst:279 msgid "" "Rather than setting ``FLASK_APP`` each time you open a new terminal, you " "can use Flask's dotenv support to set environment variables " "automatically." msgstr "" -#: ../../cli.rst:245 +#: ../../cli.rst:282 msgid "" "If `python-dotenv`_ is installed, running the ``flask`` command will set " "environment variables defined in the files :file:`.env` and " @@ -249,7 +261,7 @@ msgid "" "using environment variables similar to how some deployment services work." msgstr "" -#: ../../cli.rst:251 +#: ../../cli.rst:288 msgid "" "Variables set on the command line are used over those set in " ":file:`.env`, which are used over those set in :file:`.flaskenv`. " @@ -258,7 +270,7 @@ msgid "" "repository so that it can set private variables." msgstr "" -#: ../../cli.rst:256 +#: ../../cli.rst:293 msgid "" "Directories are scanned upwards from the directory you call ``flask`` " "from to locate the files. The current working directory will be set to " @@ -266,18 +278,18 @@ msgid "" "project directory." msgstr "" -#: ../../cli.rst:261 +#: ../../cli.rst:298 msgid "" "The files are only loaded by the ``flask`` command or calling " ":meth:`~Flask.run`. If you would like to load these files when running in" " production, you should call :func:`~cli.load_dotenv` manually." msgstr "" -#: ../../cli.rst:269 +#: ../../cli.rst:306 msgid "Setting Command Options" msgstr "" -#: ../../cli.rst:271 +#: ../../cli.rst:308 msgid "" "Click is configured to load default values for command options from " "environment variables. The variables use the pattern " @@ -285,23 +297,23 @@ msgid "" "command, instead of ``flask run --port 8000``:" msgstr "" -#: ../../cli.rst:302 +#: ../../cli.rst:347 msgid "" "These can be added to the ``.flaskenv`` file just like ``FLASK_APP`` to " "control default command options." msgstr "" -#: ../../cli.rst:307 +#: ../../cli.rst:352 msgid "Disable dotenv" msgstr "" -#: ../../cli.rst:309 +#: ../../cli.rst:354 msgid "" "The ``flask`` command will show a message if it detects dotenv files but " "python-dotenv is not installed." msgstr "" -#: ../../cli.rst:317 +#: ../../cli.rst:362 msgid "" "You can tell Flask not to load dotenv files even when python-dotenv is " "installed by setting the ``FLASK_SKIP_DOTENV`` environment variable. This" @@ -311,11 +323,11 @@ msgid "" "expected." msgstr "" -#: ../../cli.rst:349 +#: ../../cli.rst:401 msgid "Environment Variables From virtualenv" msgstr "" -#: ../../cli.rst:351 +#: ../../cli.rst:403 msgid "" "If you do not want to install dotenv support, you can still set " "environment variables by adding them to the end of the virtualenv's " @@ -323,59 +335,63 @@ msgid "" "variables." msgstr "" -#: ../../cli.rst:359 +#: ../../cli.rst:411 msgid "Unix Bash, :file:`venv/bin/activate`::" msgstr "" -#: ../../cli.rst:365 +#: ../../cli.rst:417 +msgid "Fish, :file:`venv/bin/activate.fish`::" +msgstr "" + +#: ../../cli.rst:423 msgid "Windows CMD, :file:`venv\\\\Scripts\\\\activate.bat`::" msgstr "" -#: ../../cli.rst:371 +#: ../../cli.rst:429 msgid "Windows Powershell, :file:`venv\\\\Scripts\\\\activate.ps1`::" msgstr "" -#: ../../cli.rst:375 +#: ../../cli.rst:433 msgid "" "It is preferred to use dotenv support over this, since :file:`.flaskenv` " "can be committed to the repository so that it works automatically " "wherever the project is checked out." msgstr "" -#: ../../cli.rst:381 +#: ../../cli.rst:439 msgid "Custom Commands" msgstr "" -#: ../../cli.rst:383 +#: ../../cli.rst:441 msgid "" "The ``flask`` command is implemented using `Click`_. See that project's " "documentation for full information about writing commands." msgstr "" -#: ../../cli.rst:386 +#: ../../cli.rst:444 msgid "" "This example adds the command ``create-user`` that takes the argument " "``name``. ::" msgstr "" -#: ../../cli.rst:403 +#: ../../cli.rst:461 msgid "" "This example adds the same command, but as ``user create``, a command in " "a group. This is useful if you want to organize multiple related " "commands. ::" msgstr "" -#: ../../cli.rst:424 +#: ../../cli.rst:482 msgid "" "See :ref:`testing-cli` for an overview of how to test your custom " "commands." msgstr "" -#: ../../cli.rst:429 +#: ../../cli.rst:487 msgid "Registering Commands with Blueprints" msgstr "" -#: ../../cli.rst:431 +#: ../../cli.rst:489 msgid "" "If your application uses blueprints, you can optionally register CLI " "commands directly onto them. When your blueprint is registered onto your " @@ -384,7 +400,7 @@ msgid "" "the name of the blueprint." msgstr "" -#: ../../cli.rst:454 +#: ../../cli.rst:512 msgid "" "You can alter the group name by specifying the ``cli_group`` parameter " "when creating the :class:`Blueprint` object, or later with " @@ -392,17 +408,17 @@ msgid "" "`. The following are equivalent:" msgstr "" -#: ../../cli.rst:469 +#: ../../cli.rst:527 msgid "" "Specifying ``cli_group=None`` will remove the nesting and merge the " "commands directly to the application's level:" msgstr "" -#: ../../cli.rst:484 +#: ../../cli.rst:542 msgid "Application Context" msgstr "" -#: ../../cli.rst:486 +#: ../../cli.rst:544 msgid "" "Commands added using the Flask app's :attr:`~Flask.cli` " ":meth:`~cli.AppGroup.command` decorator will be executed with an " @@ -412,15 +428,15 @@ msgid "" "use :func:`~cli.with_appcontext` to get the same behavior. ::" msgstr "" -#: ../../cli.rst:503 +#: ../../cli.rst:561 msgid "If you're sure a command doesn't need the context, you can disable it::" msgstr "" -#: ../../cli.rst:511 +#: ../../cli.rst:569 msgid "Plugins" msgstr "" -#: ../../cli.rst:513 +#: ../../cli.rst:571 msgid "" "Flask will automatically load commands specified in the " "``flask.commands`` `entry point`_. This is useful for extensions that " @@ -428,23 +444,23 @@ msgid "" "in :file:`setup.py` ::" msgstr "" -#: ../../cli.rst:532 +#: ../../cli.rst:590 msgid "" "Inside :file:`flask_my_extension/commands.py` you can then export a Click" " object::" msgstr "" -#: ../../cli.rst:541 +#: ../../cli.rst:599 msgid "" "Once that package is installed in the same virtualenv as your Flask " "project, you can run ``flask my-command`` to invoke the command." msgstr "" -#: ../../cli.rst:548 +#: ../../cli.rst:606 msgid "Custom Scripts" msgstr "" -#: ../../cli.rst:550 +#: ../../cli.rst:608 msgid "" "When you are using the app factory pattern, it may be more convenient to " "define your own Click script. Instead of using ``FLASK_APP`` and letting " @@ -452,42 +468,42 @@ msgid "" "export it as a `console script`_ entry point." msgstr "" -#: ../../cli.rst:555 +#: ../../cli.rst:613 msgid "Create an instance of :class:`~cli.FlaskGroup` and pass it the factory::" msgstr "" -#: ../../cli.rst:570 +#: ../../cli.rst:628 msgid "Define the entry point in :file:`setup.py`::" msgstr "" -#: ../../cli.rst:584 +#: ../../cli.rst:642 msgid "" "Install the application in the virtualenv in editable mode and the custom" " script is available. Note that you don't need to set ``FLASK_APP``. ::" msgstr "" -#: ../../cli.rst:590 +#: ../../cli.rst:648 msgid "Errors in Custom Scripts" msgstr "" -#: ../../cli.rst:592 +#: ../../cli.rst:650 msgid "" "When using a custom script, if you introduce an error in your module-" "level code, the reloader will fail because it can no longer load the " "entry point." msgstr "" -#: ../../cli.rst:596 +#: ../../cli.rst:654 msgid "" "The ``flask`` command, being separate from your code, does not have this " "issue and is recommended in most cases." msgstr "" -#: ../../cli.rst:603 +#: ../../cli.rst:661 msgid "PyCharm Integration" msgstr "" -#: ../../cli.rst:605 +#: ../../cli.rst:663 msgid "" "PyCharm Professional provides a special Flask run configuration. For the " "Community Edition, we need to configure it to call the ``flask run`` CLI " @@ -495,7 +511,7 @@ msgid "" " be similar for any other IDE you might want to use." msgstr "" -#: ../../cli.rst:610 +#: ../../cli.rst:668 msgid "" "In PyCharm, with your project open, click on *Run* from the menu bar and " "go to *Edit Configurations*. You'll be greeted by a screen similar to " @@ -505,7 +521,7 @@ msgstr "" msgid "Screenshot of PyCharms's run configuration settings." msgstr "" -#: ../../cli.rst:619 +#: ../../cli.rst:677 msgid "" "There's quite a few options to change, but once we've done it for one " "command, we can easily copy the entire configuration and make a single " @@ -513,7 +529,7 @@ msgid "" "may implement yourself." msgstr "" -#: ../../cli.rst:624 +#: ../../cli.rst:682 msgid "" "Click the + (*Add New Configuration*) button and select *Python*. Give " "the configuration a name such as \"flask run\". For the ``flask run`` " @@ -521,18 +537,18 @@ msgid "" "more than once at the same time." msgstr "" -#: ../../cli.rst:629 +#: ../../cli.rst:687 msgid "Select *Module name* from the dropdown (**A**) then input ``flask``." msgstr "" -#: ../../cli.rst:631 +#: ../../cli.rst:689 msgid "" "The *Parameters* field (**B**) is set to the CLI command to execute (with" " any arguments). In this example we use ``run``, which will run the " "development server." msgstr "" -#: ../../cli.rst:635 +#: ../../cli.rst:693 msgid "" "You can skip this next step if you're using :ref:`dotenv`. We need to add" " an environment variable (**C**) to identify our application. Click on " @@ -541,27 +557,27 @@ msgid "" " with ``FLASK_ENV`` and set it to ``development``." msgstr "" -#: ../../cli.rst:641 +#: ../../cli.rst:699 msgid "" "Next we need to set the working directory (**D**) to be the folder where " "our application resides." msgstr "" -#: ../../cli.rst:644 +#: ../../cli.rst:702 msgid "" "If you have installed your project as a package in your virtualenv, you " "may untick the *PYTHONPATH* options (**E**). This will more accurately " "match how you deploy the app later." msgstr "" -#: ../../cli.rst:648 +#: ../../cli.rst:706 msgid "" "Click *Apply* to save the configuration, or *OK* to save and close the " "window. Select the configuration in the main PyCharm window and click the" " play button next to it to run the server." msgstr "" -#: ../../cli.rst:652 +#: ../../cli.rst:710 msgid "" "Now that we have a configuration which runs ``flask run`` from within " "PyCharm, we can copy that configuration and alter the *Script* argument " diff --git a/docs/locales/zh_CN/LC_MESSAGES/config.po b/docs/locales/zh_CN/LC_MESSAGES/config.po index 33b947cd7..c430db25b 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/config.po +++ b/docs/locales/zh_CN/LC_MESSAGES/config.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: zh_CN \n" @@ -109,19 +109,23 @@ msgid "" " :envvar:`FLASK_ENV`:" msgstr "" -#: ../../config.rst:72 ../../config.rst:440 ../../config.rst:511 +#: ../../config.rst:72 ../../config.rst:447 ../../config.rst:526 msgid "Bash" msgstr "" -#: ../../config.rst:79 ../../config.rst:448 ../../config.rst:520 +#: ../../config.rst:79 ../../config.rst:455 ../../config.rst:535 +msgid "Fish" +msgstr "" + +#: ../../config.rst:86 ../../config.rst:463 ../../config.rst:544 msgid "CMD" msgstr "" -#: ../../config.rst:86 ../../config.rst:456 ../../config.rst:529 +#: ../../config.rst:93 ../../config.rst:471 ../../config.rst:553 msgid "Powershell" msgstr "" -#: ../../config.rst:93 +#: ../../config.rst:100 msgid "" "Using the environment variables as described above is recommended. While " "it is possible to set :data:`ENV` and :data:`DEBUG` in your config or " @@ -130,15 +134,15 @@ msgid "" "configured themselves based on a previous value." msgstr "" -#: ../../config.rst:101 +#: ../../config.rst:108 msgid "Builtin Configuration Values" msgstr "" -#: ../../config.rst:103 +#: ../../config.rst:110 msgid "The following configuration values are used internally by Flask:" msgstr "" -#: ../../config.rst:107 +#: ../../config.rst:114 msgid "" "What environment the app is running in. Flask and extensions may enable " "behaviors based on the environment, such as enabling debug mode. The " @@ -147,15 +151,15 @@ msgid "" "expected if set in code." msgstr "" -#: ../../config.rst:113 +#: ../../config.rst:120 msgid "**Do not enable development when deploying in production.**" msgstr "" -#: ../../config.rst:115 +#: ../../config.rst:122 msgid "Default: ``'production'``" msgstr "" -#: ../../config.rst:121 +#: ../../config.rst:128 msgid "" "Whether debug mode is enabled. When using ``flask run`` to start the " "development server, an interactive debugger will be shown for unhandled " @@ -166,57 +170,57 @@ msgid "" "set in code." msgstr "" -#: ../../config.rst:129 +#: ../../config.rst:136 msgid "**Do not enable debug mode when deploying in production.**" msgstr "" -#: ../../config.rst:131 +#: ../../config.rst:138 msgid "" "Default: ``True`` if :data:`ENV` is ``'development'``, or ``False`` " "otherwise." msgstr "" -#: ../../config.rst:136 +#: ../../config.rst:143 msgid "" "Enable testing mode. Exceptions are propagated rather than handled by the" " the app's error handlers. Extensions may also change their behavior to " "facilitate easier testing. You should enable this in your own tests." msgstr "" -#: ../../config.rst:140 ../../config.rst:164 ../../config.rst:225 -#: ../../config.rst:263 ../../config.rst:347 ../../config.rst:368 +#: ../../config.rst:147 ../../config.rst:171 ../../config.rst:232 +#: ../../config.rst:270 ../../config.rst:354 ../../config.rst:375 msgid "Default: ``False``" msgstr "" -#: ../../config.rst:144 +#: ../../config.rst:151 msgid "" "Exceptions are re-raised rather than being handled by the app's error " "handlers. If not set, this is implicitly true if ``TESTING`` or ``DEBUG``" " is enabled." msgstr "" -#: ../../config.rst:148 ../../config.rst:156 ../../config.rst:174 -#: ../../config.rst:188 ../../config.rst:203 ../../config.rst:210 -#: ../../config.rst:233 ../../config.rst:277 ../../config.rst:295 -#: ../../config.rst:322 ../../config.rst:360 +#: ../../config.rst:155 ../../config.rst:163 ../../config.rst:181 +#: ../../config.rst:195 ../../config.rst:210 ../../config.rst:217 +#: ../../config.rst:240 ../../config.rst:284 ../../config.rst:302 +#: ../../config.rst:329 ../../config.rst:367 msgid "Default: ``None``" msgstr "" -#: ../../config.rst:152 +#: ../../config.rst:159 msgid "" "Don't pop the request context when an exception occurs. If not set, this " "is true if ``DEBUG`` is true. This allows debuggers to introspect the " "request data on errors, and should normally not need to be set directly." msgstr "" -#: ../../config.rst:160 +#: ../../config.rst:167 msgid "" "If there is no handler for an ``HTTPException``-type exception, re-raise " "it to be handled by the interactive debugger instead of returning it as a" " simple error response." msgstr "" -#: ../../config.rst:168 +#: ../../config.rst:175 msgid "" "Trying to access a key that doesn't exist from request dicts like " "``args`` and ``form`` will return a 400 Bad Request error page. Enable " @@ -225,7 +229,7 @@ msgid "" "``TRAP_HTTP_EXCEPTIONS``. If unset, it is enabled in debug mode." msgstr "" -#: ../../config.rst:178 +#: ../../config.rst:185 msgid "" "A secret key that will be used for securely signing the session cookie " "and can be used for any other security related needs by extensions or " @@ -233,79 +237,79 @@ msgid "" "example, copy the output of this to your config::" msgstr "" -#: ../../config.rst:186 +#: ../../config.rst:193 msgid "" "**Do not reveal the secret key when posting questions or committing " "code.**" msgstr "" -#: ../../config.rst:192 +#: ../../config.rst:199 msgid "" "The name of the session cookie. Can be changed in case you already have a" " cookie with the same name." msgstr "" -#: ../../config.rst:195 +#: ../../config.rst:202 msgid "Default: ``'session'``" msgstr "" -#: ../../config.rst:199 +#: ../../config.rst:206 msgid "" "The domain match rule that the session cookie will be valid for. If not " "set, the cookie will be valid for all subdomains of :data:`SERVER_NAME`. " "If ``False``, the cookie's domain will not be set." msgstr "" -#: ../../config.rst:207 +#: ../../config.rst:214 msgid "" "The path that the session cookie will be valid for. If not set, the " "cookie will be valid underneath ``APPLICATION_ROOT`` or ``/`` if that is " "not set." msgstr "" -#: ../../config.rst:214 +#: ../../config.rst:221 msgid "" "Browsers will not allow JavaScript access to cookies marked as \"HTTP " "only\" for security." msgstr "" -#: ../../config.rst:217 ../../config.rst:255 ../../config.rst:331 -#: ../../config.rst:340 +#: ../../config.rst:224 ../../config.rst:262 ../../config.rst:338 +#: ../../config.rst:347 msgid "Default: ``True``" msgstr "" -#: ../../config.rst:221 +#: ../../config.rst:228 msgid "" "Browsers will only send cookies with requests over HTTPS if the cookie is" " marked \"secure\". The application must be served over HTTPS for this to" " make sense." msgstr "" -#: ../../config.rst:229 +#: ../../config.rst:236 msgid "" "Restrict how cookies are sent with requests from external sites. Can be " "set to ``'Lax'`` (recommended) or ``'Strict'``. See :ref:`security-" "cookie`." msgstr "" -#: ../../config.rst:239 +#: ../../config.rst:246 msgid "" "If ``session.permanent`` is true, the cookie's expiration will be set " "this number of seconds in the future. Can either be a " ":class:`datetime.timedelta` or an ``int``." msgstr "" -#: ../../config.rst:243 +#: ../../config.rst:250 msgid "" "Flask's default cookie implementation validates that the cryptographic " "signature is not older than this value." msgstr "" -#: ../../config.rst:246 +#: ../../config.rst:253 msgid "Default: ``timedelta(days=31)`` (``2678400`` seconds)" msgstr "" -#: ../../config.rst:250 +#: ../../config.rst:257 msgid "" "Control whether the cookie is sent with every response when " "``session.permanent`` is true. Sending the cookie every time (the " @@ -313,7 +317,7 @@ msgid "" "bandwidth. Non-permanent sessions are not affected." msgstr "" -#: ../../config.rst:259 +#: ../../config.rst:266 msgid "" "When serving files, set the ``X-Sendfile`` header instead of serving the " "data with Flask. Some web servers, such as Apache, recognize this and " @@ -321,7 +325,7 @@ msgid "" "server." msgstr "" -#: ../../config.rst:267 +#: ../../config.rst:274 msgid "" "When serving files, set the cache control max age to this number of " "seconds. Can be a :class:`datetime.timedelta` or an ``int``. Override " @@ -330,19 +334,19 @@ msgid "" "blueprint." msgstr "" -#: ../../config.rst:273 +#: ../../config.rst:280 msgid "" "If ``None``, ``send_file`` tells the browser to use conditional requests " "will be used instead of a timed cache, which is usually preferable." msgstr "" -#: ../../config.rst:281 +#: ../../config.rst:288 msgid "" "Inform the application what host and port it is bound to. Required for " "subdomain route matching support." msgstr "" -#: ../../config.rst:284 +#: ../../config.rst:291 msgid "" "If set, will be used for the session cookie domain if " ":data:`SESSION_COOKIE_DOMAIN` is not set. Modern web browsers will not " @@ -350,13 +354,13 @@ msgid "" " add any names that should route to the app to your ``hosts`` file. ::" msgstr "" -#: ../../config.rst:292 +#: ../../config.rst:299 msgid "" "If set, ``url_for`` can generate external URLs with only an application " "context instead of a request context." msgstr "" -#: ../../config.rst:299 +#: ../../config.rst:306 msgid "" "Inform the application what path it is mounted under by the application /" " web server. This is used for generating URLs outside the context of a " @@ -365,34 +369,34 @@ msgid "" " dispatch configuration)." msgstr "" -#: ../../config.rst:305 +#: ../../config.rst:312 msgid "" "Will be used for the session cookie path if ``SESSION_COOKIE_PATH`` is " "not set." msgstr "" -#: ../../config.rst:308 +#: ../../config.rst:315 msgid "Default: ``'/'``" msgstr "" -#: ../../config.rst:312 +#: ../../config.rst:319 msgid "" "Use this scheme for generating external URLs when not in a request " "context." msgstr "" -#: ../../config.rst:314 +#: ../../config.rst:321 msgid "Default: ``'http'``" msgstr "" -#: ../../config.rst:318 +#: ../../config.rst:325 msgid "" "Don't read more than this many bytes from the incoming request data. If " "not set and the request does not specify a ``CONTENT_LENGTH``, no data " "will be read for security." msgstr "" -#: ../../config.rst:326 +#: ../../config.rst:333 msgid "" "Serialize objects to ASCII-encoded JSON. If this is disabled, the JSON " "returned from ``jsonify`` will contain Unicode characters. This has " @@ -400,7 +404,7 @@ msgid "" "templates, and should typically remain enabled." msgstr "" -#: ../../config.rst:335 +#: ../../config.rst:342 msgid "" "Sort the keys of JSON objects alphabetically. This is useful for caching " "because it ensures the data is serialized the same way no matter what " @@ -408,102 +412,102 @@ msgid "" "possible performance improvement at the cost of caching." msgstr "" -#: ../../config.rst:344 +#: ../../config.rst:351 msgid "" "``jsonify`` responses will be output with newlines, spaces, and " "indentation for easier reading by humans. Always enabled in debug mode." msgstr "" -#: ../../config.rst:351 +#: ../../config.rst:358 msgid "The mimetype of ``jsonify`` responses." msgstr "" -#: ../../config.rst:353 +#: ../../config.rst:360 msgid "Default: ``'application/json'``" msgstr "" -#: ../../config.rst:357 +#: ../../config.rst:364 msgid "" "Reload templates when they are changed. If not set, it will be enabled in" " debug mode." msgstr "" -#: ../../config.rst:364 +#: ../../config.rst:371 msgid "" "Log debugging information tracing how a template file was loaded. This " "can be useful to figure out why a template was not loaded or the wrong " "file appears to be loaded." msgstr "" -#: ../../config.rst:372 +#: ../../config.rst:379 msgid "" "Warn if cookie headers are larger than this many bytes. Defaults to " "``4093``. Larger cookies may be silently ignored by browsers. Set to " "``0`` to disable the warning." msgstr "" -#: ../../config.rst:404 +#: ../../config.rst:411 msgid "" "``LOGGER_NAME`` and ``LOGGER_HANDLER_POLICY`` were removed. See " ":doc:`/logging` for information about configuration." msgstr "" -#: ../../config.rst:408 +#: ../../config.rst:415 msgid "Added :data:`ENV` to reflect the :envvar:`FLASK_ENV` environment variable." msgstr "" -#: ../../config.rst:411 +#: ../../config.rst:418 msgid "" "Added :data:`SESSION_COOKIE_SAMESITE` to control the session cookie's " "``SameSite`` option." msgstr "" -#: ../../config.rst:414 +#: ../../config.rst:421 msgid "Added :data:`MAX_COOKIE_SIZE` to control a warning from Werkzeug." msgstr "" -#: ../../config.rst:400 +#: ../../config.rst:407 msgid "" "``SESSION_REFRESH_EACH_REQUEST``, ``TEMPLATES_AUTO_RELOAD``, " "``LOGGER_HANDLER_POLICY``, ``EXPLAIN_TEMPLATE_LOADING``" msgstr "" -#: ../../config.rst:397 +#: ../../config.rst:404 msgid "``JSON_AS_ASCII``, ``JSON_SORT_KEYS``, ``JSONIFY_PRETTYPRINT_REGULAR``" msgstr "" -#: ../../config.rst:394 +#: ../../config.rst:401 msgid "``PREFERRED_URL_SCHEME``" msgstr "" -#: ../../config.rst:388 +#: ../../config.rst:395 msgid "" "``TRAP_BAD_REQUEST_ERRORS``, ``TRAP_HTTP_EXCEPTIONS``, " "``APPLICATION_ROOT``, ``SESSION_COOKIE_DOMAIN``, ``SESSION_COOKIE_PATH``," " ``SESSION_COOKIE_HTTPONLY``, ``SESSION_COOKIE_SECURE``" msgstr "" -#: ../../config.rst:385 +#: ../../config.rst:392 msgid "``PROPAGATE_EXCEPTIONS``, ``PRESERVE_CONTEXT_ON_EXCEPTION``" msgstr "" -#: ../../config.rst:382 +#: ../../config.rst:389 msgid "``MAX_CONTENT_LENGTH``" msgstr "" -#: ../../config.rst:379 +#: ../../config.rst:386 msgid "``SERVER_NAME``" msgstr "" -#: ../../config.rst:376 +#: ../../config.rst:383 msgid "``LOGGER_NAME``" msgstr "" -#: ../../config.rst:418 +#: ../../config.rst:425 msgid "Configuring from Python Files" msgstr "" -#: ../../config.rst:420 +#: ../../config.rst:427 msgid "" "Configuration becomes more useful if you can store it in a separate file," " ideally located outside the actual application package. This makes " @@ -512,11 +516,11 @@ msgid "" "configuration file afterwards." msgstr "" -#: ../../config.rst:426 +#: ../../config.rst:433 msgid "So a common pattern is this::" msgstr "" -#: ../../config.rst:432 +#: ../../config.rst:439 msgid "" "This first loads the configuration from the " "`yourapplication.default_settings` module and then overrides the values " @@ -525,18 +529,18 @@ msgid "" "the shell before starting the server:" msgstr "" -#: ../../config.rst:464 +#: ../../config.rst:479 msgid "" "The configuration files themselves are actual Python files. Only values " "in uppercase are actually stored in the config object later on. So make " "sure to use uppercase letters for your config keys." msgstr "" -#: ../../config.rst:468 +#: ../../config.rst:483 msgid "Here is an example of a configuration file::" msgstr "" -#: ../../config.rst:473 +#: ../../config.rst:488 msgid "" "Make sure to load the configuration very early on, so that extensions " "have the ability to access the configuration when starting up. There are" @@ -545,57 +549,57 @@ msgid "" "object's documentation." msgstr "" -#: ../../config.rst:481 +#: ../../config.rst:496 msgid "Configuring from Data Files" msgstr "" -#: ../../config.rst:483 +#: ../../config.rst:498 msgid "" "It is also possible to load configuration from a file in a format of your" " choice using :meth:`~flask.Config.from_file`. For example to load from a" " TOML file:" msgstr "" -#: ../../config.rst:492 +#: ../../config.rst:507 msgid "Or from a JSON file:" msgstr "" -#: ../../config.rst:501 +#: ../../config.rst:516 msgid "Configuring from Environment Variables" msgstr "" -#: ../../config.rst:503 +#: ../../config.rst:518 msgid "" "In addition to pointing to configuration files using environment " "variables, you may find it useful (or necessary) to control your " "configuration values directly from the environment." msgstr "" -#: ../../config.rst:507 +#: ../../config.rst:522 msgid "Environment variables can be set in the shell before starting the server:" msgstr "" -#: ../../config.rst:538 +#: ../../config.rst:562 msgid "" "While this approach is straightforward to use, it is important to " "remember that environment variables are strings -- they are not " "automatically deserialized into Python types." msgstr "" -#: ../../config.rst:542 +#: ../../config.rst:566 msgid "" "Here is an example of a configuration file that uses environment " "variables::" msgstr "" -#: ../../config.rst:555 +#: ../../config.rst:579 msgid "" "Notice that any value besides an empty string will be interpreted as a " "boolean ``True`` value in Python, which requires care if an environment " "explicitly sets values intended to be ``False``." msgstr "" -#: ../../config.rst:559 +#: ../../config.rst:583 msgid "" "Make sure to load the configuration very early on, so that extensions " "have the ability to access the configuration when starting up. There are" @@ -604,11 +608,11 @@ msgid "" "documentation." msgstr "" -#: ../../config.rst:566 +#: ../../config.rst:590 msgid "Configuration Best Practices" msgstr "" -#: ../../config.rst:568 +#: ../../config.rst:592 #, python-format msgid "" "The downside with the approach mentioned earlier is that it makes testing" @@ -617,7 +621,7 @@ msgid "" " that experience:" msgstr "" -#: ../../config.rst:573 +#: ../../config.rst:597 msgid "" "Create your application in a function and register blueprints on it. That" " way you can create multiple instances of your application with different" @@ -625,18 +629,18 @@ msgid "" "use this to pass in configuration as needed." msgstr "" -#: ../../config.rst:578 +#: ../../config.rst:602 msgid "" "Do not write code that needs the configuration at import time. If you " "limit yourself to request-only accesses to the configuration you can " "reconfigure the object later on as needed." msgstr "" -#: ../../config.rst:585 +#: ../../config.rst:609 msgid "Development / Production" msgstr "" -#: ../../config.rst:587 +#: ../../config.rst:611 msgid "" "Most applications need more than one configuration. There should be at " "least separate configurations for the production server and the one used " @@ -646,7 +650,7 @@ msgid "" "mentioned in the example above::" msgstr "" -#: ../../config.rst:598 +#: ../../config.rst:622 msgid "" "Then you just have to add a separate :file:`config.py` file and export " "``YOURAPPLICATION_SETTINGS=/path/to/config.py`` and you are done. " @@ -654,7 +658,7 @@ msgid "" "imports or subclassing." msgstr "" -#: ../../config.rst:603 +#: ../../config.rst:627 msgid "" "What is very popular in the Django world is to make the import explicit " "in the config file by adding ``from yourapplication.default_settings " @@ -664,19 +668,19 @@ msgid "" "and import different hard-coded files based on that." msgstr "" -#: ../../config.rst:610 +#: ../../config.rst:634 msgid "" "An interesting pattern is also to use classes and inheritance for " "configuration::" msgstr "" -#: ../../config.rst:626 +#: ../../config.rst:650 msgid "" "To enable such a config you just have to call into " ":meth:`~flask.Config.from_object`::" msgstr "" -#: ../../config.rst:631 +#: ../../config.rst:655 msgid "" "Note that :meth:`~flask.Config.from_object` does not instantiate the " "class object. If you need to instantiate the class, such as to access a " @@ -684,26 +688,26 @@ msgid "" ":meth:`~flask.Config.from_object`::" msgstr "" -#: ../../config.rst:643 +#: ../../config.rst:667 msgid "" "Instantiating the configuration object allows you to use ``@property`` in" " your configuration classes::" msgstr "" -#: ../../config.rst:666 +#: ../../config.rst:690 msgid "" "There are many different ways and it's up to you how you want to manage " "your configuration files. However here a list of good recommendations:" msgstr "" -#: ../../config.rst:669 +#: ../../config.rst:693 msgid "" "Keep a default configuration in version control. Either populate the " "config with this default configuration or import it in your own " "configuration files before overriding values." msgstr "" -#: ../../config.rst:672 +#: ../../config.rst:696 msgid "" "Use an environment variable to switch between the configurations. This " "can be done from outside the Python interpreter and makes development and" @@ -714,18 +718,18 @@ msgid "" "configuration for you." msgstr "" -#: ../../config.rst:679 +#: ../../config.rst:703 msgid "" "Use a tool like `fabric`_ in production to push code and configurations " "separately to the production server(s). For some details about how to do" " that, head over to the :doc:`/patterns/fabric` pattern." msgstr "" -#: ../../config.rst:690 +#: ../../config.rst:714 msgid "Instance Folders" msgstr "" -#: ../../config.rst:694 +#: ../../config.rst:718 msgid "" "Flask 0.8 introduces instance folders. Flask for a long time made it " "possible to refer to paths relative to the application's folder directly " @@ -735,7 +739,7 @@ msgid "" "root path refers to the contents of the package." msgstr "" -#: ../../config.rst:701 +#: ../../config.rst:725 msgid "" "With Flask 0.8 a new attribute was introduced: " ":attr:`Flask.instance_path`. It refers to a new concept called the " @@ -744,7 +748,7 @@ msgid "" "drop things that either change at runtime or configuration files." msgstr "" -#: ../../config.rst:707 +#: ../../config.rst:731 msgid "" "You can either explicitly provide the path of the instance folder when " "creating the Flask application or you can let Flask autodetect the " @@ -752,36 +756,36 @@ msgid "" "parameter::" msgstr "" -#: ../../config.rst:714 +#: ../../config.rst:738 msgid "Please keep in mind that this path *must* be absolute when provided." msgstr "" -#: ../../config.rst:716 +#: ../../config.rst:740 msgid "" "If the `instance_path` parameter is not provided the following default " "locations are used:" msgstr "" -#: ../../config.rst:719 +#: ../../config.rst:743 msgid "Uninstalled module::" msgstr "" -#: ../../config.rst:724 +#: ../../config.rst:748 msgid "Uninstalled package::" msgstr "" -#: ../../config.rst:730 +#: ../../config.rst:754 msgid "Installed module or package::" msgstr "" -#: ../../config.rst:735 +#: ../../config.rst:759 msgid "" "``$PREFIX`` is the prefix of your Python installation. This can be " "``/usr`` or the path to your virtualenv. You can print the value of " "``sys.prefix`` to see what the prefix is set to." msgstr "" -#: ../../config.rst:739 +#: ../../config.rst:763 msgid "" "Since the config object provided loading of configuration files from " "relative filenames we made it possible to change the loading via " @@ -791,20 +795,20 @@ msgid "" "`instance_relative_config` switch to the application constructor::" msgstr "" -#: ../../config.rst:748 +#: ../../config.rst:772 msgid "" "Here is a full example of how to configure Flask to preload the config " "from a module and then override the config from a file in the instance " "folder if it exists::" msgstr "" -#: ../../config.rst:756 +#: ../../config.rst:780 msgid "" "The path to the instance folder can be found via the " ":attr:`Flask.instance_path`. Flask also provides a shortcut to open a " "file from the instance folder with :meth:`Flask.open_instance_resource`." msgstr "" -#: ../../config.rst:760 +#: ../../config.rst:784 msgid "Example usage for both::" msgstr "" diff --git a/docs/locales/zh_CN/LC_MESSAGES/contributing.po b/docs/locales/zh_CN/LC_MESSAGES/contributing.po index 88bc08578..dda93ea25 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/contributing.po +++ b/docs/locales/zh_CN/LC_MESSAGES/contributing.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Grey Li \n" "Language-Team: zh_CN \n" @@ -36,12 +36,12 @@ msgid "" "following resources for questions about using Flask or issues with your " "own code:" msgstr "" -"请不要使用 issue tracker 提问。issue tracker 是一个用来报告 Flask 本身的 bug 以及" -"提出新特性请求的工具。对于使用 Flask 时遇到的问题,或是关于你自己代码的问题,请" -"使用下面的资源获取帮助:" +"请不要使用 issue tracker 提问。issue tracker 是一个用来报告 Flask 本身的 bug " +"以及提出新特性请求的工具。对于使用 Flask 时遇到的问题,或是关于你自己代码的问题,请使用下面的资源获取帮助:" #: ../../../CONTRIBUTING.rst:15 -msgid "The ``#get-help`` channel on our Discord chat: https://discord.gg/pallets" +#, fuzzy +msgid "The ``#questions`` channel on our Discord chat: https://discord.gg/pallets" msgstr "我们的 Discord 聊天组的 ``#questions`` 频道:https://discord.gg/pallets" #: ../../../CONTRIBUTING.rst:17 @@ -55,51 +55,50 @@ msgid "" "Ask on `Stack Overflow`_. Search with Google first using: " "``site:stackoverflow.com flask {search term, exception message, etc.}``" msgstr "" -"在 `Stack Overflow`_ 上提问。先使用 ``site:stackoverflow.com flask {搜索关" -"键词,异常信息等}`` 在 Google 上搜索。" +"在 `Stack Overflow`_ 上提问。先使用 ``site:stackoverflow.com flask " +"{搜索关键词,异常信息等}`` 在 Google 上搜索。" + +#: ../../../CONTRIBUTING.rst:21 +msgid "Ask on our `GitHub Discussions`_." +msgstr "" -#: ../../../CONTRIBUTING.rst:26 +#: ../../../CONTRIBUTING.rst:28 msgid "Reporting issues" msgstr "报告 issue" -#: ../../../CONTRIBUTING.rst:28 +#: ../../../CONTRIBUTING.rst:30 msgid "Include the following information in your post:" msgstr "在帖子里包含下列信息:" -#: ../../../CONTRIBUTING.rst:30 +#: ../../../CONTRIBUTING.rst:32 msgid "Describe what you expected to happen." msgstr "描述期待发生的情况。" -#: ../../../CONTRIBUTING.rst:31 +#: ../../../CONTRIBUTING.rst:33 msgid "" "If possible, include a `minimal reproducible example`_ to help us " "identify the issue. This also helps check that the issue is not with your" " own code." -msgstr "" -"如果可能的话,提供一个 `最小的可复现的示例`_ 来帮助我们识别 issue。这也会帮助" -"我们确认问题是否出自你自己的代码。" +msgstr "如果可能的话,提供一个 `最小的可复现的示例`_ 来帮助我们识别 issue。这也会帮助我们确认问题是否出自你自己的代码。" -#: ../../../CONTRIBUTING.rst:34 +#: ../../../CONTRIBUTING.rst:36 msgid "" "Describe what actually happened. Include the full traceback if there was " "an exception." -msgstr "" -"描述实际发生的情况。如果有异常发生,给出完整的错误堆栈信息。" +msgstr "描述实际发生的情况。如果有异常发生,给出完整的错误堆栈信息。" -#: ../../../CONTRIBUTING.rst:36 +#: ../../../CONTRIBUTING.rst:38 msgid "" "List your Python and Flask versions. If possible, check if this issue is " "already fixed in the latest releases or the latest code in the " "repository." -msgstr "" -"列出 Python 和 Flask 的版本。如果可能的话,检查这个 issue 是不是已经在最新发布的" -"版本中或最新的代码仓库中修复。" +msgstr "列出 Python 和 Flask 的版本。如果可能的话,检查这个 issue 是不是已经在最新发布的版本中或最新的代码仓库中修复。" -#: ../../../CONTRIBUTING.rst:44 +#: ../../../CONTRIBUTING.rst:46 msgid "Submitting patches" msgstr "提交补丁" -#: ../../../CONTRIBUTING.rst:46 +#: ../../../CONTRIBUTING.rst:48 msgid "" "If there is not an open issue for what you want to submit, prefer opening" " one for discussion before working on a PR. You can work on any issue " @@ -107,193 +106,179 @@ msgid "" " These show up in the sidebar. No need to ask if you can work on an issue" " that interests you." msgstr "" -"如果你提交的补丁没有对应的开启的 issue,建议在开始工作前创建一个 issue 进行讨论。" -"你可以着手处理任何没有链接某个开启的 PR 或分配维护者的 issue(这些信息可以在边栏看到)。" -"不需要问是否能处理你感兴趣的 issue,尽管动手去做。" +"如果你提交的补丁没有对应的开启的 issue,建议在开始工作前创建一个 issue 进行讨论。你可以着手处理任何没有链接某个开启的 PR " +"或分配维护者的 issue(这些信息可以在边栏看到)。不需要问是否能处理你感兴趣的 issue,尽管动手去做。" -#: ../../../CONTRIBUTING.rst:52 +#: ../../../CONTRIBUTING.rst:54 msgid "Include the following in your patch:" msgstr "在补丁里包含下列内容:" -#: ../../../CONTRIBUTING.rst:54 +#: ../../../CONTRIBUTING.rst:56 msgid "" "Use `Black`_ to format your code. This and other tools will run " "automatically if you install `pre-commit`_ using the instructions below." -msgstr "" -"使用 `Black`_ 格式化代码。如果安装了 `pre-commit`_ 并使用下面的操作步骤," -"那么它和其他工具会自动运行。" +msgstr "使用 `Black`_ 格式化代码。如果安装了 `pre-commit`_ 并使用下面的操作步骤,那么它和其他工具会自动运行。" -#: ../../../CONTRIBUTING.rst:57 +#: ../../../CONTRIBUTING.rst:59 msgid "" "Include tests if your patch adds or changes code. Make sure the test " "fails without your patch." -msgstr "" -"如果你的补丁增加或改变了某些代码,记得添加对应的测试。确保在没有你的补丁时测试" -"不会通过。" +msgstr "如果你的补丁增加或改变了某些代码,记得添加对应的测试。确保在没有你的补丁时测试不会通过。" -#: ../../../CONTRIBUTING.rst:59 +#: ../../../CONTRIBUTING.rst:61 msgid "" "Update any relevant docs pages and docstrings. Docs pages and docstrings " "should be wrapped at 72 characters." -msgstr "" -"更新任何相关的文档页面和文档字符串。文档页面和文档字符串的行长度应该控制在 72 个" -"字符以内。" +msgstr "更新任何相关的文档页面和文档字符串。文档页面和文档字符串的行长度应该控制在 72 个字符以内。" -#: ../../../CONTRIBUTING.rst:61 +#: ../../../CONTRIBUTING.rst:63 msgid "" "Add an entry in ``CHANGES.rst``. Use the same style as other entries. " "Also include ``.. versionchanged::`` inline changelogs in relevant " "docstrings." msgstr "" -"在 ``CHANGES.rst`` 中添加一个条目。使用和其他条目相同的行文风格。同时在相关" -"的文档字符串使用 ``.. versionchanged::`` 标签添加行内变更日志。" +"在 ``CHANGES.rst`` 中添加一个条目。使用和其他条目相同的行文风格。同时在相关的文档字符串使用 ``.. " +"versionchanged::`` 标签添加行内变更日志。" -#: ../../../CONTRIBUTING.rst:70 +#: ../../../CONTRIBUTING.rst:72 msgid "First time setup" msgstr "首次设置" -#: ../../../CONTRIBUTING.rst:72 +#: ../../../CONTRIBUTING.rst:74 msgid "Download and install the `latest version of git`_." msgstr "下载并安装 `最新版本的 git`_。" -#: ../../../CONTRIBUTING.rst:73 +#: ../../../CONTRIBUTING.rst:75 msgid "Configure git with your `username`_ and `email`_." msgstr "使用你的 `用户名`_ 和 `Email`_ 配置 git。" -#: ../../../CONTRIBUTING.rst:80 +#: ../../../CONTRIBUTING.rst:82 msgid "Make sure you have a `GitHub account`_." msgstr "确保你有一个 `GitHub 账号`_。" -#: ../../../CONTRIBUTING.rst:81 +#: ../../../CONTRIBUTING.rst:83 msgid "Fork Flask to your GitHub account by clicking the `Fork`_ button." msgstr "点击 `Fork`_ 按钮把 Flask 复刻(Fork)到你的 GitHub 仓库。" -#: ../../../CONTRIBUTING.rst:82 +#: ../../../CONTRIBUTING.rst:84 msgid "`Clone`_ the main repository locally." msgstr "把仓库 `克隆`_ 到本地。" -#: ../../../CONTRIBUTING.rst:89 +#: ../../../CONTRIBUTING.rst:91 msgid "" "Add your fork as a remote to push your work to. Replace ``{username}`` " "with your username. This names the remote \"fork\", the default Pallets " "remote is \"origin\"." msgstr "" -"把你的复刻仓库作为推送工作代码的远程仓库。使用你的用户名替代 ``{username}``。" -"这会把远程仓库命名为“fork”,默认的 Pallets 远程仓库为“origin”。" +"把你的复刻仓库作为推送工作代码的远程仓库。使用你的用户名替代 ``{username}``。这会把远程仓库命名为“fork”,默认的 " +"Pallets 远程仓库为“origin”。" -#: ../../../CONTRIBUTING.rst:97 +#: ../../../CONTRIBUTING.rst:99 msgid "Create a virtualenv." msgstr "创建一个虚拟环境。" -#: ../../../CONTRIBUTING.rst:101 +#: ../../../CONTRIBUTING.rst:103 msgid "Linux/macOS" msgstr "Linux/macOS" -#: ../../../CONTRIBUTING.rst:108 +#: ../../../CONTRIBUTING.rst:110 msgid "Windows" msgstr "Windows" -#: ../../../CONTRIBUTING.rst:115 +#: ../../../CONTRIBUTING.rst:117 msgid "Upgrade pip and setuptools." msgstr "更新 pip 和 setuptools。" -#: ../../../CONTRIBUTING.rst:121 +#: ../../../CONTRIBUTING.rst:123 msgid "Install the development dependencies, then install Flask in editable mode." msgstr "安装开发依赖,然后以编辑模式安装 Flask。" -#: ../../../CONTRIBUTING.rst:128 +#: ../../../CONTRIBUTING.rst:130 msgid "Install the pre-commit hooks." msgstr "安装 pre-commit 钩子。" -#: ../../../CONTRIBUTING.rst:143 +#: ../../../CONTRIBUTING.rst:145 msgid "Start coding" msgstr "开始写代码" -#: ../../../CONTRIBUTING.rst:145 +#: ../../../CONTRIBUTING.rst:147 msgid "" "Create a branch to identify the issue you would like to work on. If " "you're submitting a bug or documentation fix, branch off of the latest " "\".x\" branch." -msgstr "" -"创建一个分支来标识你想要处理的 issue。如果你在修复一个 bug 或是文档错误,使用" -"最新的“.x”分支作为基础分支。" +msgstr "创建一个分支来标识你想要处理的 issue。如果你在修复一个 bug 或是文档错误,使用最新的“.x”分支作为基础分支。" -#: ../../../CONTRIBUTING.rst:154 +#: ../../../CONTRIBUTING.rst:156 msgid "" "If you're submitting a feature addition or change, branch off of the " "\"main\" branch." msgstr "如果你正在提交一个新特性或变动,使用“main”分支作为基础分支。" -#: ../../../CONTRIBUTING.rst:162 +#: ../../../CONTRIBUTING.rst:164 msgid "Using your favorite editor, make your changes, `committing as you go`_." msgstr "使用你最喜欢的编辑器做出改动,`大胆提交代码`_。" -#: ../../../CONTRIBUTING.rst:164 +#: ../../../CONTRIBUTING.rst:166 msgid "" "Include tests that cover any code changes you make. Make sure the test " "fails without your patch. Run the tests as described below." -msgstr "" -"包含覆盖所有变动代码的测试。确保测试在没有你的补丁时会失败。参考下面的说明运行测试。" +msgstr "包含覆盖所有变动代码的测试。确保测试在没有你的补丁时会失败。参考下面的说明运行测试。" -#: ../../../CONTRIBUTING.rst:166 +#: ../../../CONTRIBUTING.rst:168 msgid "" "Push your commits to your fork on GitHub and `create a pull request`_. " "Link to the issue being addressed with ``fixes #123`` in the pull " "request." msgstr "" -"把你的提交推送到在 GitHub 上的派生仓库并 `创建一个拉取请求(pull request)`_。" -"在拉取请求中使用 ``fixes #123`` 链接到关联的 issue。" +"把你的提交推送到在 GitHub 上的派生仓库并 `创建一个拉取请求(pull request)`_。在拉取请求中使用 ``fixes " +"#123`` 链接到关联的 issue。" -#: ../../../CONTRIBUTING.rst:179 +#: ../../../CONTRIBUTING.rst:181 msgid "Running the tests" msgstr "运行测试" -#: ../../../CONTRIBUTING.rst:181 +#: ../../../CONTRIBUTING.rst:183 msgid "Run the basic test suite with pytest." msgstr "使用 pytest 运行基本测试套件。" -#: ../../../CONTRIBUTING.rst:187 +#: ../../../CONTRIBUTING.rst:189 msgid "" "This runs the tests for the current environment, which is usually " "sufficient. CI will run the full suite when you submit your pull request." " You can run the full test suite with tox if you don't want to wait." -msgstr "" -"这会为当前环境运行测试,这通常就足够了。在提交拉取请求时,CI 会运行完整的测试套件。" -"如果你不想等待的话可以使用 tox 运行完整的测试套件。" +msgstr "这会为当前环境运行测试,这通常就足够了。在提交拉取请求时,CI 会运行完整的测试套件。如果你不想等待的话可以使用 tox 运行完整的测试套件。" -#: ../../../CONTRIBUTING.rst:198 +#: ../../../CONTRIBUTING.rst:200 msgid "Running test coverage" msgstr "运行测试覆盖率检查" -#: ../../../CONTRIBUTING.rst:200 +#: ../../../CONTRIBUTING.rst:202 msgid "" "Generating a report of lines that do not have test coverage can indicate " "where to start contributing. Run ``pytest`` using ``coverage`` and " "generate a report." -msgstr "" -"生成一份包含测试未覆盖行数的报告,可以指明从哪里开始增加测试。通过 ``coverage`` 执" -"行 ``pytest`` 来生成报告。" +msgstr "生成一份包含测试未覆盖行数的报告,可以指明从哪里开始增加测试。通过 ``coverage`` 执行 ``pytest`` 来生成报告。" -#: ../../../CONTRIBUTING.rst:210 +#: ../../../CONTRIBUTING.rst:212 msgid "Open ``htmlcov/index.html`` in your browser to explore the report." msgstr "使用浏览器打开 ``htmlcov/index.html`` 浏览报告。" -#: ../../../CONTRIBUTING.rst:212 +#: ../../../CONTRIBUTING.rst:214 msgid "Read more about `coverage `__." msgstr "更多内容请参阅 `coverage 文档 `__。" -#: ../../../CONTRIBUTING.rst:216 +#: ../../../CONTRIBUTING.rst:218 msgid "Building the docs" msgstr "构建文档" -#: ../../../CONTRIBUTING.rst:218 +#: ../../../CONTRIBUTING.rst:220 msgid "Build the docs in the ``docs`` directory using Sphinx." msgstr "在 ``docs`` 目录使用 Sphinx 构建文档。" -#: ../../../CONTRIBUTING.rst:225 +#: ../../../CONTRIBUTING.rst:227 msgid "Open ``_build/html/index.html`` in your browser to view the docs." msgstr "使用浏览器打开 ``_build/html/index.html`` 预览文档。" -#: ../../../CONTRIBUTING.rst:227 +#: ../../../CONTRIBUTING.rst:229 msgid "Read more about `Sphinx `__." msgstr "更多内容请参阅 `Sphinx 文档 `__。" diff --git a/docs/locales/zh_CN/LC_MESSAGES/debugging.po b/docs/locales/zh_CN/LC_MESSAGES/debugging.po index 5c8aa6c13..62b40b800 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/debugging.po +++ b/docs/locales/zh_CN/LC_MESSAGES/debugging.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: zh_CN \n" @@ -77,27 +77,31 @@ msgid "" "and reloader." msgstr "" -#: ../../debugging.rst:49 ../../debugging.rst:102 +#: ../../debugging.rst:49 ../../debugging.rst:109 msgid "Bash" msgstr "" -#: ../../debugging.rst:56 ../../debugging.rst:109 +#: ../../debugging.rst:56 ../../debugging.rst:116 +msgid "Fish" +msgstr "" + +#: ../../debugging.rst:63 ../../debugging.rst:123 msgid "CMD" msgstr "" -#: ../../debugging.rst:63 ../../debugging.rst:116 +#: ../../debugging.rst:70 ../../debugging.rst:130 msgid "Powershell" msgstr "" -#: ../../debugging.rst:70 +#: ../../debugging.rst:77 msgid "" "``FLASK_ENV`` can only be set as an environment variable. When running " "from Python code, passing ``debug=True`` enables debug mode, which is " -"mostly equivalent. Debug mode can be controled separately from " +"mostly equivalent. Debug mode can be controlled separately from " "``FLASK_ENV`` with the ``FLASK_DEBUG`` environment variable as well." msgstr "" -#: ../../debugging.rst:79 +#: ../../debugging.rst:86 msgid "" ":doc:`/server` and :doc:`/cli` have more information about running the " "debugger, debug mode, and development mode. More information about the " @@ -105,11 +109,11 @@ msgid "" "`__." msgstr "" -#: ../../debugging.rst:86 +#: ../../debugging.rst:93 msgid "External Debuggers" msgstr "" -#: ../../debugging.rst:88 +#: ../../debugging.rst:95 msgid "" "External debuggers, such as those provided by IDEs, can offer a more " "powerful debugging experience than the built-in debugger. They can also " @@ -118,22 +122,22 @@ msgid "" "code running on another machine." msgstr "" -#: ../../debugging.rst:94 +#: ../../debugging.rst:101 msgid "" "When using an external debugger, the app should still be in debug mode, " "but it can be useful to disable the built-in debugger and reloader, which" " can interfere." msgstr "" -#: ../../debugging.rst:98 +#: ../../debugging.rst:105 msgid "When running from the command line:" msgstr "" -#: ../../debugging.rst:123 +#: ../../debugging.rst:137 msgid "When running from Python:" msgstr "" -#: ../../debugging.rst:129 +#: ../../debugging.rst:143 msgid "" "Disabling these isn't required, an external debugger will continue to " "work with the following caveats. If the built-in debugger is not " @@ -141,3 +145,13 @@ msgid "" " can. If the reloader is not disabled, it could cause an unexpected " "reload if code changes during debugging." msgstr "" + +#~ msgid "" +#~ "``FLASK_ENV`` can only be set as " +#~ "an environment variable. When running " +#~ "from Python code, passing ``debug=True`` " +#~ "enables debug mode, which is mostly " +#~ "equivalent. Debug mode can be controled" +#~ " separately from ``FLASK_ENV`` with the " +#~ "``FLASK_DEBUG`` environment variable as well." +#~ msgstr "" diff --git a/docs/locales/zh_CN/LC_MESSAGES/deploying/asgi.po b/docs/locales/zh_CN/LC_MESSAGES/deploying/asgi.po index 36c7d66ec..4c546bd7a 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/deploying/asgi.po +++ b/docs/locales/zh_CN/LC_MESSAGES/deploying/asgi.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Jiahua Wang \n" "Language-Team: zh_CN \n" @@ -22,22 +22,24 @@ msgid "ASGI" msgstr "ASGI" #: ../../deploying/asgi.rst:6 +#, fuzzy msgid "" "If you'd like to use an ASGI server you will need to utilise WSGI to ASGI" -" middleware. The asgiref [WsgiToAsgi](https://github.com/django/asgiref" -"#wsgi-to-asgi-adapter) adapter is recommended as it integrates with the " -"event loop used for Flask's :ref:`async_await` support. You can use the " +" middleware. The asgiref `WsgiToAsgi `_ adapter is recommended as it integrates with the" +" event loop used for Flask's :ref:`async_await` support. You can use the " "adapter by wrapping the Flask app," msgstr "" -"如果你想要使用 ASGI 服务器,你需要利用 WSGI 到 ASGI 的中间件。推荐使用" -"asgiref [WsgiToAsgi](https://github.com/django/asgiref#wsgi-to-asgi-adapter)" -"适配器,因为它与 Flask 的 :ref:`async_await` 支持使用的事件循环集成。" -"你可以使用这个适配器来包装 Flask 应用," +"如果你想要使用 ASGI 服务器,你需要利用 WSGI 到 ASGI 的中间件。推荐使用asgiref " +"[WsgiToAsgi](https://github.com/django/asgiref#wsgi-to-asgi-" +"adapter)适配器,因为它与 Flask 的 :ref:`async_await` 支持使用的事件循环集成。你可以使用这个适配器来包装 " +"Flask 应用," #: ../../deploying/asgi.rst:24 +#, fuzzy msgid "" -"and then serving the ``asgi_app`` with the asgi server, e.g. using " +"and then serving the ``asgi_app`` with the ASGI server, e.g. using " "`Hypercorn `_," msgstr "" -"然后使用 asgi 服务器为 ``asgi_app`` 提供服务。例如,使用" -"`Hypercorn `_," +"然后使用 asgi 服务器为 ``asgi_app`` 提供服务。例如,使用`Hypercorn " +"`_," diff --git a/docs/locales/zh_CN/LC_MESSAGES/deploying/uwsgi.po b/docs/locales/zh_CN/LC_MESSAGES/deploying/uwsgi.po index ce88f4b91..2e69d2f47 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/deploying/uwsgi.po +++ b/docs/locales/zh_CN/LC_MESSAGES/deploying/uwsgi.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: zh_CN \n" @@ -71,7 +71,7 @@ msgid "" "``myapp`` refers to the name of the file of your flask application " "(without extension) or the module which provides ``app``. ``app`` is the " "callable inside of your application (usually the line reads ``app = " -"Flask(__name__)``." +"Flask(__name__)``)." msgstr "" #: ../../deploying/uwsgi.rst:42 @@ -96,3 +96,22 @@ msgid "" "This configuration binds the application to ``/yourapplication``. If you" " want to have it in the URL root its a bit simpler::" msgstr "" + +#~ msgid "" +#~ "The ``--manage-script-name`` will move" +#~ " the handling of ``SCRIPT_NAME`` to " +#~ "uwsgi, since it is smarter about " +#~ "that. It is used together with the" +#~ " ``--mount`` directive which will make " +#~ "requests to ``/yourapplication`` be directed" +#~ " to ``myapp:app``. If your application " +#~ "is accessible at root level, you " +#~ "can use a single ``/`` instead of" +#~ " ``/yourapplication``. ``myapp`` refers to " +#~ "the name of the file of your " +#~ "flask application (without extension) or " +#~ "the module which provides ``app``. " +#~ "``app`` is the callable inside of " +#~ "your application (usually the line reads" +#~ " ``app = Flask(__name__)``." +#~ msgstr "" diff --git a/docs/locales/zh_CN/LC_MESSAGES/index.po b/docs/locales/zh_CN/LC_MESSAGES/index.po index 1afc4cd4b..80d2ec758 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/index.po +++ b/docs/locales/zh_CN/LC_MESSAGES/index.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Grey Li \n" "Language-Team: zh_CN \n" @@ -21,8 +21,8 @@ msgstr "" msgid "Welcome to Flask" msgstr "欢迎来到 Flask 的世界" -msgid "Flask: web development, one drop at a time" -msgstr "Flask:Web 开发,一次一滴" +msgid "Flask:Web 开发,一次一滴" +msgstr "" #: ../../index.rst:11 msgid "" @@ -34,18 +34,16 @@ msgid "" "component of Flask in detail, with a full reference in the :doc:`api` " "section." msgstr "" -"欢迎来到 Flask 的文档。你可以从 :doc:`installation` 入手,然后阅读 " -":doc:`quickstart` 来了解基本概念。还有一个包含更多细节的 :doc:`tutorial/index` " -"介绍如何用 Flask 创建一个很小但是完整的程序。一般的开发模式可以在 " -":doc:`patterns/index` 章节找到。剩下的文档详细的介绍了 Flask 的每一个组成部件," -"其中 :doc:`api` 章节包括完整的 API 参考信息。" +"欢迎来到 Flask 的文档。你可以从 :doc:`installation` 入手,然后阅读 :doc:`quickstart` " +"来了解基本概念。还有一个包含更多细节的 :doc:`tutorial/index` 介绍如何用 Flask " +"创建一个很小但是完整的程序。一般的开发模式可以在 :doc:`patterns/index` 章节找到。剩下的文档详细的介绍了 Flask " +"的每一个组成部件,其中 :doc:`api` 章节包括完整的 API 参考信息。" #: ../../index.rst:19 msgid "" "Flask depends on the `Jinja`_ template engine and the `Werkzeug`_ WSGI " "toolkit. The documentation for these libraries can be found at:" -msgstr "" -"Flask 依赖 `Jinja`_ 模板引擎和 `Werkzeug`_ WSGI 工具集。这些库的文档如下:" +msgstr "Flask 依赖 `Jinja`_ 模板引擎和 `Werkzeug`_ WSGI 工具集。这些库的文档如下:" #: ../../index.rst:22 msgid "`Jinja documentation `_" @@ -64,9 +62,7 @@ msgid "" "This part of the documentation, which is mostly prose, begins with some " "background information about Flask, then focuses on step-by-step " "instructions for web development with Flask." -msgstr "" -"这部分的文档大部分是独立章节,以一些关于 Flask 的背景信息开始,然后重点介绍如何" -"使用 Flask 一步步进行 Web 开发。" +msgstr "这部分的文档大部分是独立章节,以一些关于 Flask 的背景信息开始,然后重点介绍如何使用 Flask 一步步进行 Web 开发。" #: ../../index.rst:66 msgid "API Reference" @@ -76,8 +72,7 @@ msgstr "API 参考" msgid "" "If you are looking for information on a specific function, class or " "method, this part of the documentation is for you." -msgstr "" -"如果你想找关于某个特定函数、类或方法的信息,那么这部分文档就是为你准备的。" +msgstr "如果你想找关于某个特定函数、类或方法的信息,那么这部分文档就是为你准备的。" #: ../../index.rst:78 msgid "Additional Notes" @@ -86,3 +81,6 @@ msgstr "附加笔记" #: ../../index.rst:80 msgid "Design notes, legal information and changelog are here for the interested." msgstr "如果你感兴趣的话,这里有一些设计笔记、法律信息和变更日志(changelog)。" + +#~ msgid "Flask: web development, one drop at a time" +#~ msgstr "Flask:Web 开发,一次一滴" diff --git a/docs/locales/zh_CN/LC_MESSAGES/patterns/appfactories.po b/docs/locales/zh_CN/LC_MESSAGES/patterns/appfactories.po index 6af4d726e..def9656c4 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/patterns/appfactories.po +++ b/docs/locales/zh_CN/LC_MESSAGES/patterns/appfactories.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: zh_CN \n" @@ -115,55 +115,59 @@ msgstr "" msgid "To run such an application, you can use the :command:`flask` command:" msgstr "" -#: ../../patterns/appfactories.rst:94 ../../patterns/appfactories.rst:120 +#: ../../patterns/appfactories.rst:94 ../../patterns/appfactories.rst:127 msgid "Bash" msgstr "" -#: ../../patterns/appfactories.rst:101 ../../patterns/appfactories.rst:127 +#: ../../patterns/appfactories.rst:101 ../../patterns/appfactories.rst:134 +msgid "Fish" +msgstr "" + +#: ../../patterns/appfactories.rst:108 ../../patterns/appfactories.rst:141 msgid "CMD" msgstr "" -#: ../../patterns/appfactories.rst:108 ../../patterns/appfactories.rst:134 +#: ../../patterns/appfactories.rst:115 ../../patterns/appfactories.rst:148 msgid "Powershell" msgstr "" -#: ../../patterns/appfactories.rst:115 +#: ../../patterns/appfactories.rst:122 msgid "" "Flask will automatically detect the factory (``create_app`` or " "``make_app``) in ``myapp``. You can also pass arguments to the factory " "like this:" msgstr "" -#: ../../patterns/appfactories.rst:141 +#: ../../patterns/appfactories.rst:155 msgid "" "Then the ``create_app`` factory in ``myapp`` is called with the string " "``'dev'`` as the argument. See :doc:`/cli` for more detail." msgstr "" -#: ../../patterns/appfactories.rst:145 +#: ../../patterns/appfactories.rst:159 msgid "Factory Improvements" msgstr "" -#: ../../patterns/appfactories.rst:147 +#: ../../patterns/appfactories.rst:161 msgid "" "The factory function above is not very clever, but you can improve it. " "The following changes are straightforward to implement:" msgstr "" -#: ../../patterns/appfactories.rst:150 +#: ../../patterns/appfactories.rst:164 msgid "" "Make it possible to pass in configuration values for unit tests so that " "you don't have to create config files on the filesystem." msgstr "" -#: ../../patterns/appfactories.rst:152 +#: ../../patterns/appfactories.rst:166 msgid "" "Call a function from a blueprint when the application is setting up so " "that you have a place to modify attributes of the application (like " "hooking in before/after request handlers etc.)" msgstr "" -#: ../../patterns/appfactories.rst:155 +#: ../../patterns/appfactories.rst:169 msgid "" "Add in WSGI middlewares when the application is being created if " "necessary." diff --git a/docs/locales/zh_CN/LC_MESSAGES/patterns/celery.po b/docs/locales/zh_CN/LC_MESSAGES/patterns/celery.po index a77409cb8..41d20eb26 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/patterns/celery.po +++ b/docs/locales/zh_CN/LC_MESSAGES/patterns/celery.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: zh_CN \n" @@ -89,7 +89,7 @@ msgstr "" msgid "" "Let's write a task that adds two numbers together and returns the result." " We configure Celery's broker and backend to use Redis, create a " -"``celery`` application using the factor from above, and then use it to " +"``celery`` application using the factory from above, and then use it to " "define the task. ::" msgstr "" @@ -120,3 +120,13 @@ msgid "" "Now that the worker is running, ``wait`` will return the result once the " "task is finished." msgstr "" + +#~ msgid "" +#~ "Let's write a task that adds two" +#~ " numbers together and returns the " +#~ "result. We configure Celery's broker and" +#~ " backend to use Redis, create a " +#~ "``celery`` application using the factor " +#~ "from above, and then use it to " +#~ "define the task. ::" +#~ msgstr "" diff --git a/docs/locales/zh_CN/LC_MESSAGES/patterns/fileuploads.po b/docs/locales/zh_CN/LC_MESSAGES/patterns/fileuploads.po index ec79dee14..f8195986c 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/patterns/fileuploads.po +++ b/docs/locales/zh_CN/LC_MESSAGES/patterns/fileuploads.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: zh_CN \n" @@ -198,7 +198,18 @@ msgstr "" #: ../../patterns/fileuploads.rst:177 msgid "" "Because the common pattern for file uploads exists almost unchanged in " -"all applications dealing with uploads, there is also a Flask extension " -"called `Flask-Uploads`_ that implements a full fledged upload mechanism " -"that allows controlling which file extensions are allowed to be uploaded." -msgstr "" +"all applications dealing with uploads, there are also some Flask " +"extensions that implement a full fledged upload mechanism that allows " +"controlling which file extensions are allowed to be uploaded." +msgstr "" + +#~ msgid "" +#~ "Because the common pattern for file " +#~ "uploads exists almost unchanged in all" +#~ " applications dealing with uploads, there" +#~ " is also a Flask extension called " +#~ "`Flask-Uploads`_ that implements a full" +#~ " fledged upload mechanism that allows " +#~ "controlling which file extensions are " +#~ "allowed to be uploaded." +#~ msgstr "" diff --git a/docs/locales/zh_CN/LC_MESSAGES/patterns/packages.po b/docs/locales/zh_CN/LC_MESSAGES/patterns/packages.po index 67794d153..33dfc3ef7 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/patterns/packages.po +++ b/docs/locales/zh_CN/LC_MESSAGES/patterns/packages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: zh_CN \n" @@ -46,7 +46,7 @@ msgid "" "most likely break)" msgstr "" -#: ../../patterns/packages.rst:29 ../../patterns/packages.rst:139 +#: ../../patterns/packages.rst:29 ../../patterns/packages.rst:151 msgid "You should then end up with something like that::" msgstr "" @@ -65,46 +65,50 @@ msgid "" "variable that tells Flask where to find the application instance:" msgstr "" -#: ../../patterns/packages.rst:64 ../../patterns/packages.rst:88 +#: ../../patterns/packages.rst:64 ../../patterns/packages.rst:94 msgid "Bash" msgstr "" -#: ../../patterns/packages.rst:70 ../../patterns/packages.rst:94 +#: ../../patterns/packages.rst:70 ../../patterns/packages.rst:100 +msgid "Fish" +msgstr "" + +#: ../../patterns/packages.rst:76 ../../patterns/packages.rst:106 msgid "CMD" msgstr "" -#: ../../patterns/packages.rst:76 ../../patterns/packages.rst:100 +#: ../../patterns/packages.rst:82 ../../patterns/packages.rst:112 msgid "Powershell" msgstr "" -#: ../../patterns/packages.rst:82 +#: ../../patterns/packages.rst:88 msgid "" "If you are outside of the project directory make sure to provide the " "exact path to your application directory. Similarly you can turn on the " "development features like this:" msgstr "" -#: ../../patterns/packages.rst:106 +#: ../../patterns/packages.rst:118 msgid "" "In order to install and run the application you need to issue the " "following commands::" msgstr "" -#: ../../patterns/packages.rst:112 +#: ../../patterns/packages.rst:124 msgid "" "What did we gain from this? Now we can restructure the application a bit" " into multiple modules. The only thing you have to remember is the " "following quick checklist:" msgstr "" -#: ../../patterns/packages.rst:116 +#: ../../patterns/packages.rst:128 msgid "" "the `Flask` application object creation has to be in the " ":file:`__init__.py` file. That way each module can import it safely and " "the `__name__` variable will resolve to the correct package." msgstr "" -#: ../../patterns/packages.rst:119 +#: ../../patterns/packages.rst:131 msgid "" "all the view functions (the ones with a :meth:`~flask.Flask.route` " "decorator on top) have to be imported in the :file:`__init__.py` file. " @@ -112,19 +116,19 @@ msgid "" "**after the application object is created**." msgstr "" -#: ../../patterns/packages.rst:124 +#: ../../patterns/packages.rst:136 msgid "Here's an example :file:`__init__.py`::" msgstr "" -#: ../../patterns/packages.rst:131 +#: ../../patterns/packages.rst:143 msgid "And this is what :file:`views.py` would look like::" msgstr "" -#: ../../patterns/packages.rst:154 +#: ../../patterns/packages.rst:166 msgid "Circular Imports" msgstr "" -#: ../../patterns/packages.rst:156 +#: ../../patterns/packages.rst:168 msgid "" "Every Python programmer hates them, and yet we just added some: circular " "imports (That's when two modules depend on each other. In this case " @@ -135,18 +139,18 @@ msgid "" "bottom of the file." msgstr "" -#: ../../patterns/packages.rst:164 +#: ../../patterns/packages.rst:176 msgid "" "There are still some problems with that approach but if you want to use " "decorators there is no way around that. Check out the " ":doc:`/becomingbig` section for some inspiration how to deal with that." msgstr "" -#: ../../patterns/packages.rst:170 +#: ../../patterns/packages.rst:182 msgid "Working with Blueprints" msgstr "" -#: ../../patterns/packages.rst:172 +#: ../../patterns/packages.rst:184 msgid "" "If you have larger applications it's recommended to divide them into " "smaller groups where each group is implemented with the help of a " diff --git a/docs/locales/zh_CN/LC_MESSAGES/quickstart.po b/docs/locales/zh_CN/LC_MESSAGES/quickstart.po index 2c93a2859..05a4fd5c8 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/quickstart.po +++ b/docs/locales/zh_CN/LC_MESSAGES/quickstart.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: zh_CN \n" @@ -82,47 +82,58 @@ msgid "" "environment variable:" msgstr "" -#: ../../quickstart.rst:49 ../../quickstart.rst:157 +#: ../../quickstart.rst:49 ../../quickstart.rst:170 msgid "Bash" msgstr "" -#: ../../quickstart.rst:57 ../../quickstart.rst:164 +#: ../../quickstart.rst:57 ../../quickstart.rst:177 +msgid "Fish" +msgstr "" + +#: ../../quickstart.rst:65 ../../quickstart.rst:184 msgid "CMD" msgstr "" -#: ../../quickstart.rst:65 ../../quickstart.rst:171 +#: ../../quickstart.rst:73 ../../quickstart.rst:191 msgid "Powershell" msgstr "" -#: ../../quickstart.rst:73 +#: ../../quickstart.rst:81 msgid "Application Discovery Behavior" msgstr "" -#: ../../quickstart.rst:75 +#: ../../quickstart.rst:83 msgid "" "As a shortcut, if the file is named ``app.py`` or ``wsgi.py``, you don't " "have to set the ``FLASK_APP`` environment variable. See :doc:`/cli` for " "more details." msgstr "" -#: ../../quickstart.rst:79 +#: ../../quickstart.rst:87 msgid "" "This launches a very simple builtin server, which is good enough for " "testing but probably not what you want to use in production. For " "deployment options see :doc:`deploying/index`." msgstr "" -#: ../../quickstart.rst:83 +#: ../../quickstart.rst:91 msgid "" "Now head over to http://127.0.0.1:5000/, and you should see your hello " "world greeting." msgstr "" -#: ../../quickstart.rst:88 +#: ../../quickstart.rst:94 +msgid "" +"If another program is already using port 5000, you'll see ``OSError: " +"[Errno 98]`` or ``OSError: [WinError 10013]`` when the server tries to " +"start. See :ref:`address-already-in-use` for how to handle that." +msgstr "" + +#: ../../quickstart.rst:101 msgid "Externally Visible Server" msgstr "" -#: ../../quickstart.rst:90 +#: ../../quickstart.rst:103 msgid "" "If you run the server you will notice that the server is only accessible " "from your own computer, not from any other in the network. This is the " @@ -130,33 +141,33 @@ msgid "" "arbitrary Python code on your computer." msgstr "" -#: ../../quickstart.rst:95 +#: ../../quickstart.rst:108 msgid "" "If you have the debugger disabled or trust the users on your network, you" " can make the server publicly available simply by adding " "``--host=0.0.0.0`` to the command line::" msgstr "" -#: ../../quickstart.rst:101 +#: ../../quickstart.rst:114 msgid "This tells your operating system to listen on all public IPs." msgstr "" -#: ../../quickstart.rst:105 +#: ../../quickstart.rst:118 msgid "What to do if the Server does not Start" msgstr "" -#: ../../quickstart.rst:107 +#: ../../quickstart.rst:120 msgid "" "In case the :command:`python -m flask` fails or :command:`flask` does not" " exist, there are multiple reasons this might be the case. First of all " "you need to look at the error message." msgstr "" -#: ../../quickstart.rst:112 +#: ../../quickstart.rst:125 msgid "Old Version of Flask" msgstr "" -#: ../../quickstart.rst:114 +#: ../../quickstart.rst:127 msgid "" "Versions of Flask older than 0.11 used to have different ways to start " "the application. In short, the :command:`flask` command did not exist, " @@ -165,11 +176,11 @@ msgid "" ":doc:`/server` to see the alternative method for running a server." msgstr "" -#: ../../quickstart.rst:121 +#: ../../quickstart.rst:134 msgid "Invalid Import Name" msgstr "" -#: ../../quickstart.rst:123 +#: ../../quickstart.rst:136 msgid "" "The ``FLASK_APP`` environment variable is the name of the module to " "import at :command:`flask run`. In case that module is incorrectly named " @@ -178,17 +189,17 @@ msgid "" "and why it failed." msgstr "" -#: ../../quickstart.rst:128 +#: ../../quickstart.rst:141 msgid "" "The most common reason is a typo or because you did not actually create " "an ``app`` object." msgstr "" -#: ../../quickstart.rst:133 +#: ../../quickstart.rst:146 msgid "Debug Mode" msgstr "" -#: ../../quickstart.rst:135 +#: ../../quickstart.rst:148 msgid "" "The ``flask run`` command can do more than just start the development " "server. By enabling debug mode, the server will automatically reload if " @@ -199,46 +210,46 @@ msgstr "" msgid "The interactive debugger in action." msgstr "" -#: ../../quickstart.rst:147 +#: ../../quickstart.rst:160 msgid "" "The debugger allows executing arbitrary Python code from the browser. It " "is protected by a pin, but still represents a major security risk. Do not" " run the development server or debugger in a production environment." msgstr "" -#: ../../quickstart.rst:152 +#: ../../quickstart.rst:165 msgid "" "To enable all development features, set the ``FLASK_ENV`` environment " "variable to ``development`` before calling ``flask run``." msgstr "" -#: ../../quickstart.rst:178 +#: ../../quickstart.rst:198 msgid "See also:" msgstr "" -#: ../../quickstart.rst:180 +#: ../../quickstart.rst:200 msgid "" ":doc:`/server` and :doc:`/cli` for information about running in " "development mode." msgstr "" -#: ../../quickstart.rst:182 +#: ../../quickstart.rst:202 msgid "" ":doc:`/debugging` for information about using the built-in debugger and " "other debuggers." msgstr "" -#: ../../quickstart.rst:184 +#: ../../quickstart.rst:204 msgid "" ":doc:`/logging` and :doc:`/errorhandling` to log errors and display nice " "error pages." msgstr "" -#: ../../quickstart.rst:189 +#: ../../quickstart.rst:209 msgid "HTML Escaping" msgstr "" -#: ../../quickstart.rst:191 +#: ../../quickstart.rst:211 msgid "" "When returning HTML (the default response type in Flask), any user-" "provided values rendered in the output must be escaped to protect from " @@ -246,54 +257,54 @@ msgid "" "will do this automatically." msgstr "" -#: ../../quickstart.rst:196 +#: ../../quickstart.rst:216 msgid "" ":func:`~markupsafe.escape`, shown here, can be used manually. It is " "omitted in most examples for brevity, but you should always be aware of " "how you're using untrusted data." msgstr "" -#: ../../quickstart.rst:208 +#: ../../quickstart.rst:228 msgid "" "If a user managed to submit the name ````," " escaping causes it to be rendered as text, rather than running the " "script in the user's browser." msgstr "" -#: ../../quickstart.rst:212 +#: ../../quickstart.rst:232 msgid "" "```` in the route captures a value from the URL and passes it to " "the view function. These variable rules are explained below." msgstr "" -#: ../../quickstart.rst:217 +#: ../../quickstart.rst:237 msgid "Routing" msgstr "" -#: ../../quickstart.rst:219 +#: ../../quickstart.rst:239 msgid "" "Modern web applications use meaningful URLs to help users. Users are more" " likely to like a page and come back if the page uses a meaningful URL " "they can remember and use to directly visit a page." msgstr "" -#: ../../quickstart.rst:223 +#: ../../quickstart.rst:243 msgid "" "Use the :meth:`~flask.Flask.route` decorator to bind a function to a URL." " ::" msgstr "" -#: ../../quickstart.rst:233 +#: ../../quickstart.rst:253 msgid "" "You can do more! You can make parts of the URL dynamic and attach " "multiple rules to a function." msgstr "" -#: ../../quickstart.rst:237 +#: ../../quickstart.rst:257 msgid "Variable Rules" msgstr "" -#: ../../quickstart.rst:239 +#: ../../quickstart.rst:259 msgid "" "You can add variable sections to a URL by marking sections with " "````. Your function then receives the ```` " @@ -301,59 +312,59 @@ msgid "" " type of the argument like ````. ::" msgstr "" -#: ../../quickstart.rst:261 +#: ../../quickstart.rst:281 msgid "Converter types:" msgstr "" -#: ../../quickstart.rst:264 +#: ../../quickstart.rst:284 msgid "``string``" msgstr "" -#: ../../quickstart.rst:264 +#: ../../quickstart.rst:284 msgid "(default) accepts any text without a slash" msgstr "" -#: ../../quickstart.rst:265 +#: ../../quickstart.rst:285 msgid "``int``" msgstr "" -#: ../../quickstart.rst:265 +#: ../../quickstart.rst:285 msgid "accepts positive integers" msgstr "" -#: ../../quickstart.rst:266 +#: ../../quickstart.rst:286 msgid "``float``" msgstr "" -#: ../../quickstart.rst:266 +#: ../../quickstart.rst:286 msgid "accepts positive floating point values" msgstr "" -#: ../../quickstart.rst:267 +#: ../../quickstart.rst:287 msgid "``path``" msgstr "" -#: ../../quickstart.rst:267 +#: ../../quickstart.rst:287 msgid "like ``string`` but also accepts slashes" msgstr "" -#: ../../quickstart.rst:268 +#: ../../quickstart.rst:288 msgid "``uuid``" msgstr "" -#: ../../quickstart.rst:268 +#: ../../quickstart.rst:288 msgid "accepts UUID strings" msgstr "" -#: ../../quickstart.rst:273 +#: ../../quickstart.rst:293 msgid "Unique URLs / Redirection Behavior" msgstr "" -#: ../../quickstart.rst:275 +#: ../../quickstart.rst:295 msgid "The following two rules differ in their use of a trailing slash. ::" msgstr "" -#: ../../quickstart.rst:285 +#: ../../quickstart.rst:305 msgid "" "The canonical URL for the ``projects`` endpoint has a trailing slash. " "It's similar to a folder in a file system. If you access the URL without " @@ -361,7 +372,7 @@ msgid "" "URL with the trailing slash (``/projects/``)." msgstr "" -#: ../../quickstart.rst:290 +#: ../../quickstart.rst:310 msgid "" "The canonical URL for the ``about`` endpoint does not have a trailing " "slash. It's similar to the pathname of a file. Accessing the URL with a " @@ -370,11 +381,11 @@ msgid "" "avoid indexing the same page twice." msgstr "" -#: ../../quickstart.rst:300 +#: ../../quickstart.rst:320 msgid "URL Building" msgstr "" -#: ../../quickstart.rst:302 +#: ../../quickstart.rst:322 msgid "" "To build a URL to a specific function, use the :func:`~flask.url_for` " "function. It accepts the name of the function as its first argument and " @@ -383,40 +394,40 @@ msgid "" "parameters." msgstr "" -#: ../../quickstart.rst:307 +#: ../../quickstart.rst:327 msgid "" "Why would you want to build URLs using the URL reversing function " ":func:`~flask.url_for` instead of hard-coding them into your templates?" msgstr "" -#: ../../quickstart.rst:310 +#: ../../quickstart.rst:330 msgid "Reversing is often more descriptive than hard-coding the URLs." msgstr "" -#: ../../quickstart.rst:311 +#: ../../quickstart.rst:331 msgid "" "You can change your URLs in one go instead of needing to remember to " "manually change hard-coded URLs." msgstr "" -#: ../../quickstart.rst:313 +#: ../../quickstart.rst:333 msgid "URL building handles escaping of special characters transparently." msgstr "" -#: ../../quickstart.rst:314 +#: ../../quickstart.rst:334 msgid "" "The generated paths are always absolute, avoiding unexpected behavior of " "relative paths in browsers." msgstr "" -#: ../../quickstart.rst:316 +#: ../../quickstart.rst:336 msgid "" "If your application is placed outside the URL root, for example, in " "``/myapplication`` instead of ``/``, :func:`~flask.url_for` properly " "handles that for you." msgstr "" -#: ../../quickstart.rst:320 +#: ../../quickstart.rst:340 msgid "" "For example, here we use the :meth:`~flask.Flask.test_request_context` " "method to try out :func:`~flask.url_for`. " @@ -425,11 +436,11 @@ msgid "" ":`context-locals`." msgstr "" -#: ../../quickstart.rst:356 +#: ../../quickstart.rst:376 msgid "HTTP Methods" msgstr "" -#: ../../quickstart.rst:358 +#: ../../quickstart.rst:378 msgid "" "Web applications use different HTTP methods when accessing URLs. You " "should familiarize yourself with the HTTP methods as you work with Flask." @@ -438,18 +449,18 @@ msgid "" "handle different HTTP methods. ::" msgstr "" -#: ../../quickstart.rst:373 +#: ../../quickstart.rst:393 msgid "" "If ``GET`` is present, Flask automatically adds support for the ``HEAD`` " "method and handles ``HEAD`` requests according to the `HTTP RFC`_. " "Likewise, ``OPTIONS`` is automatically implemented for you." msgstr "" -#: ../../quickstart.rst:380 +#: ../../quickstart.rst:400 msgid "Static Files" msgstr "" -#: ../../quickstart.rst:382 +#: ../../quickstart.rst:402 msgid "" "Dynamic web applications also need static files. That's usually where " "the CSS and JavaScript files are coming from. Ideally your web server is" @@ -459,21 +470,21 @@ msgid "" "application." msgstr "" -#: ../../quickstart.rst:388 +#: ../../quickstart.rst:408 msgid "" "To generate URLs for static files, use the special ``'static'`` endpoint " "name::" msgstr "" -#: ../../quickstart.rst:392 +#: ../../quickstart.rst:412 msgid "The file has to be stored on the filesystem as :file:`static/style.css`." msgstr "" -#: ../../quickstart.rst:395 +#: ../../quickstart.rst:415 msgid "Rendering Templates" msgstr "" -#: ../../quickstart.rst:397 +#: ../../quickstart.rst:417 msgid "" "Generating HTML from within Python is not fun, and actually pretty " "cumbersome because you have to do the HTML escaping on your own to keep " @@ -482,7 +493,7 @@ msgid "" "automatically." msgstr "" -#: ../../quickstart.rst:402 +#: ../../quickstart.rst:422 msgid "" "To render a template you can use the :func:`~flask.render_template` " "method. All you have to do is provide the name of the template and the " @@ -490,40 +501,41 @@ msgid "" "Here's a simple example of how to render a template::" msgstr "" -#: ../../quickstart.rst:414 +#: ../../quickstart.rst:434 msgid "" "Flask will look for templates in the :file:`templates` folder. So if " "your application is a module, this folder is next to that module, if it's" " a package it's actually inside your package:" msgstr "" -#: ../../quickstart.rst:418 +#: ../../quickstart.rst:438 msgid "**Case 1**: a module::" msgstr "" -#: ../../quickstart.rst:424 +#: ../../quickstart.rst:444 msgid "**Case 2**: a package::" msgstr "" -#: ../../quickstart.rst:431 +#: ../../quickstart.rst:451 msgid "" "For templates you can use the full power of Jinja2 templates. Head over " "to the official `Jinja2 Template Documentation " "`_ for more information." msgstr "" -#: ../../quickstart.rst:435 +#: ../../quickstart.rst:455 msgid "Here is an example template:" msgstr "" -#: ../../quickstart.rst:447 +#: ../../quickstart.rst:467 msgid "" -"Inside templates you also have access to the :class:`~flask.request`, " -":class:`~flask.session` and :class:`~flask.g` [#]_ objects as well as the" -" :func:`~flask.get_flashed_messages` function." +"Inside templates you also have access to the :data:`~flask.Flask.config`," +" :class:`~flask.request`, :class:`~flask.session` and :class:`~flask.g` " +"[#]_ objects as well as the :func:`~flask.url_for` and " +":func:`~flask.get_flashed_messages` functions." msgstr "" -#: ../../quickstart.rst:451 +#: ../../quickstart.rst:471 msgid "" "Templates are especially useful if inheritance is used. If you want to " "know how that works, see :doc:`patterns/templateinheritance`. Basically " @@ -531,7 +543,7 @@ msgid "" "page (like header, navigation and footer)." msgstr "" -#: ../../quickstart.rst:456 +#: ../../quickstart.rst:476 msgid "" "Automatic escaping is enabled, so if ``name`` contains HTML it will be " "escaped automatically. If you can trust a variable and you know that it " @@ -541,13 +553,13 @@ msgid "" " template. Head over to the Jinja 2 documentation for more examples." msgstr "" -#: ../../quickstart.rst:463 +#: ../../quickstart.rst:483 msgid "" "Here is a basic introduction to how the :class:`~markupsafe.Markup` class" " works::" msgstr "" -#: ../../quickstart.rst:475 +#: ../../quickstart.rst:495 msgid "" "Autoescaping is no longer enabled for all templates. The following " "extensions for templates trigger autoescaping: ``.html``, ``.htm``, " @@ -555,18 +567,18 @@ msgid "" "autoescaping disabled." msgstr "" -#: ../../quickstart.rst:480 +#: ../../quickstart.rst:500 msgid "" "Unsure what that :class:`~flask.g` object is? It's something in which you" " can store information for your own needs. See the documentation for " ":class:`flask.g` and :doc:`patterns/sqlite3`." msgstr "" -#: ../../quickstart.rst:486 +#: ../../quickstart.rst:506 msgid "Accessing Request Data" msgstr "" -#: ../../quickstart.rst:488 +#: ../../quickstart.rst:508 msgid "" "For web applications it's crucial to react to the data a client sends to " "the server. In Flask this information is provided by the global " @@ -575,21 +587,21 @@ msgid "" "manages to still be threadsafe. The answer is context locals:" msgstr "" -#: ../../quickstart.rst:498 +#: ../../quickstart.rst:518 msgid "Context Locals" msgstr "" -#: ../../quickstart.rst:500 +#: ../../quickstart.rst:520 msgid "Insider Information" msgstr "" -#: ../../quickstart.rst:502 +#: ../../quickstart.rst:522 msgid "" "If you want to understand how that works and how you can implement tests " "with context locals, read this section, otherwise just skip it." msgstr "" -#: ../../quickstart.rst:505 +#: ../../quickstart.rst:525 msgid "" "Certain objects in Flask are global objects, but not of the usual kind. " "These objects are actually proxies to objects that are local to a " @@ -597,7 +609,7 @@ msgid "" "understand." msgstr "" -#: ../../quickstart.rst:509 +#: ../../quickstart.rst:529 msgid "" "Imagine the context being the handling thread. A request comes in and " "the web server decides to spawn a new thread (or something else, the " @@ -609,7 +621,7 @@ msgid "" "another application without breaking." msgstr "" -#: ../../quickstart.rst:518 +#: ../../quickstart.rst:538 msgid "" "So what does this mean to you? Basically you can completely ignore that " "this is the case unless you are doing something like unit testing. You " @@ -622,17 +634,17 @@ msgid "" "that you can interact with it. Here is an example::" msgstr "" -#: ../../quickstart.rst:535 +#: ../../quickstart.rst:555 msgid "" "The other possibility is passing a whole WSGI environment to the " ":meth:`~flask.Flask.request_context` method::" msgstr "" -#: ../../quickstart.rst:542 +#: ../../quickstart.rst:562 msgid "The Request Object" msgstr "" -#: ../../quickstart.rst:544 +#: ../../quickstart.rst:564 msgid "" "The request object is documented in the API section and we will not cover" " it here in detail (see :class:`~flask.Request`). Here is a broad " @@ -640,7 +652,7 @@ msgid "" " import it from the ``flask`` module::" msgstr "" -#: ../../quickstart.rst:551 +#: ../../quickstart.rst:571 msgid "" "The current request method is available by using the " ":attr:`~flask.Request.method` attribute. To access form data (data " @@ -649,7 +661,7 @@ msgid "" " attributes mentioned above::" msgstr "" -#: ../../quickstart.rst:570 +#: ../../quickstart.rst:590 msgid "" "What happens if the key does not exist in the ``form`` attribute? In " "that case a special :exc:`KeyError` is raised. You can catch it like a " @@ -658,37 +670,37 @@ msgid "" "deal with that problem." msgstr "" -#: ../../quickstart.rst:576 +#: ../../quickstart.rst:596 msgid "" "To access parameters submitted in the URL (``?key=value``) you can use " "the :attr:`~flask.Request.args` attribute::" msgstr "" -#: ../../quickstart.rst:581 +#: ../../quickstart.rst:601 msgid "" "We recommend accessing URL parameters with `get` or by catching the " ":exc:`KeyError` because users might change the URL and presenting them a " "400 bad request page in that case is not user friendly." msgstr "" -#: ../../quickstart.rst:585 +#: ../../quickstart.rst:605 msgid "" "For a full list of methods and attributes of the request object, head " "over to the :class:`~flask.Request` documentation." msgstr "" -#: ../../quickstart.rst:590 +#: ../../quickstart.rst:610 msgid "File Uploads" msgstr "" -#: ../../quickstart.rst:592 +#: ../../quickstart.rst:612 msgid "" "You can handle uploaded files with Flask easily. Just make sure not to " "forget to set the ``enctype=\"multipart/form-data\"`` attribute on your " "HTML form, otherwise the browser will not transmit your files at all." msgstr "" -#: ../../quickstart.rst:596 +#: ../../quickstart.rst:616 msgid "" "Uploaded files are stored in memory or at a temporary location on the " "filesystem. You can access those files by looking at the " @@ -700,7 +712,7 @@ msgid "" "example showing how that works::" msgstr "" -#: ../../quickstart.rst:614 +#: ../../quickstart.rst:634 msgid "" "If you want to know how the file was named on the client before it was " "uploaded to your application, you can access the " @@ -712,15 +724,15 @@ msgid "" "for you::" msgstr "" -#: ../../quickstart.rst:632 +#: ../../quickstart.rst:652 msgid "For some better examples, see :doc:`patterns/fileuploads`." msgstr "" -#: ../../quickstart.rst:635 +#: ../../quickstart.rst:655 msgid "Cookies" msgstr "" -#: ../../quickstart.rst:637 +#: ../../quickstart.rst:657 msgid "" "To access cookies you can use the :attr:`~flask.Request.cookies` " "attribute. To set cookies you can use the " @@ -732,15 +744,15 @@ msgid "" "you." msgstr "" -#: ../../quickstart.rst:645 +#: ../../quickstart.rst:665 msgid "Reading cookies::" msgstr "" -#: ../../quickstart.rst:655 +#: ../../quickstart.rst:675 msgid "Storing cookies::" msgstr "" -#: ../../quickstart.rst:665 +#: ../../quickstart.rst:685 msgid "" "Note that cookies are set on response objects. Since you normally just " "return strings from the view functions Flask will convert them into " @@ -748,58 +760,58 @@ msgid "" "the :meth:`~flask.make_response` function and then modify it." msgstr "" -#: ../../quickstart.rst:670 +#: ../../quickstart.rst:690 msgid "" "Sometimes you might want to set a cookie at a point where the response " "object does not exist yet. This is possible by utilizing the " ":doc:`patterns/deferredcallbacks` pattern." msgstr "" -#: ../../quickstart.rst:674 +#: ../../quickstart.rst:694 msgid "For this also see :ref:`about-responses`." msgstr "" -#: ../../quickstart.rst:677 +#: ../../quickstart.rst:697 msgid "Redirects and Errors" msgstr "" -#: ../../quickstart.rst:679 +#: ../../quickstart.rst:699 msgid "" "To redirect a user to another endpoint, use the :func:`~flask.redirect` " "function; to abort a request early with an error code, use the " ":func:`~flask.abort` function::" msgstr "" -#: ../../quickstart.rst:694 +#: ../../quickstart.rst:714 msgid "" "This is a rather pointless example because a user will be redirected from" " the index to a page they cannot access (401 means access denied) but it " "shows how that works." msgstr "" -#: ../../quickstart.rst:698 +#: ../../quickstart.rst:718 msgid "" "By default a black and white error page is shown for each error code. If" " you want to customize the error page, you can use the " ":meth:`~flask.Flask.errorhandler` decorator::" msgstr "" -#: ../../quickstart.rst:708 +#: ../../quickstart.rst:728 msgid "" "Note the ``404`` after the :func:`~flask.render_template` call. This " "tells Flask that the status code of that page should be 404 which means " "not found. By default 200 is assumed which translates to: all went well." msgstr "" -#: ../../quickstart.rst:712 +#: ../../quickstart.rst:732 msgid "See :doc:`errorhandling` for more details." msgstr "" -#: ../../quickstart.rst:717 +#: ../../quickstart.rst:737 msgid "About Responses" msgstr "" -#: ../../quickstart.rst:719 +#: ../../quickstart.rst:739 msgid "" "The return value from a view function is automatically converted into a " "response object for you. If the return value is a string it's converted " @@ -810,23 +822,23 @@ msgid "" "follows:" msgstr "" -#: ../../quickstart.rst:727 +#: ../../quickstart.rst:747 msgid "" "If a response object of the correct type is returned it's directly " "returned from the view." msgstr "" -#: ../../quickstart.rst:729 +#: ../../quickstart.rst:749 msgid "" "If it's a string, a response object is created with that data and the " "default parameters." msgstr "" -#: ../../quickstart.rst:731 +#: ../../quickstart.rst:751 msgid "If it's a dict, a response object is created using ``jsonify``." msgstr "" -#: ../../quickstart.rst:732 +#: ../../quickstart.rst:752 msgid "" "If a tuple is returned the items in the tuple can provide extra " "information. Such tuples have to be in the form ``(response, status)``, " @@ -835,41 +847,41 @@ msgid "" "list or dictionary of additional header values." msgstr "" -#: ../../quickstart.rst:738 +#: ../../quickstart.rst:758 msgid "" "If none of that works, Flask will assume the return value is a valid WSGI" " application and convert that into a response object." msgstr "" -#: ../../quickstart.rst:741 +#: ../../quickstart.rst:761 msgid "" "If you want to get hold of the resulting response object inside the view " "you can use the :func:`~flask.make_response` function." msgstr "" -#: ../../quickstart.rst:744 +#: ../../quickstart.rst:764 msgid "Imagine you have a view like this::" msgstr "" -#: ../../quickstart.rst:752 +#: ../../quickstart.rst:772 msgid "" "You just need to wrap the return expression with " ":func:`~flask.make_response` and get the response object to modify it, " "then return it::" msgstr "" -#: ../../quickstart.rst:766 +#: ../../quickstart.rst:786 msgid "APIs with JSON" msgstr "" -#: ../../quickstart.rst:768 +#: ../../quickstart.rst:788 msgid "" "A common response format when writing an API is JSON. It's easy to get " "started writing such an API with Flask. If you return a ``dict`` from a " "view, it will be converted to a JSON response." msgstr "" -#: ../../quickstart.rst:783 +#: ../../quickstart.rst:803 msgid "" "Depending on your API design, you may want to create JSON responses for " "types other than ``dict``. In that case, use the " @@ -878,11 +890,11 @@ msgid "" " complex applications." msgstr "" -#: ../../quickstart.rst:802 +#: ../../quickstart.rst:822 msgid "Sessions" msgstr "" -#: ../../quickstart.rst:804 +#: ../../quickstart.rst:824 msgid "" "In addition to the request object there is also a second object called " ":class:`~flask.session` which allows you to store information specific to" @@ -892,17 +904,17 @@ msgid "" "modify it, unless they know the secret key used for signing." msgstr "" -#: ../../quickstart.rst:811 +#: ../../quickstart.rst:831 msgid "" "In order to use sessions you have to set a secret key. Here is how " "sessions work::" msgstr "" -#: ../../quickstart.rst:843 +#: ../../quickstart.rst:863 msgid "How to generate good secret keys" msgstr "" -#: ../../quickstart.rst:845 +#: ../../quickstart.rst:865 msgid "" "A secret key should be as random as possible. Your operating system has " "ways to generate pretty random data based on a cryptographic random " @@ -910,7 +922,7 @@ msgid "" ":attr:`Flask.secret_key` (or :data:`SECRET_KEY`)::" msgstr "" -#: ../../quickstart.rst:853 +#: ../../quickstart.rst:873 msgid "" "A note on cookie-based sessions: Flask will take the values you put into " "the session object and serialize them into a cookie. If you are finding " @@ -920,18 +932,18 @@ msgid "" "browsers." msgstr "" -#: ../../quickstart.rst:859 +#: ../../quickstart.rst:879 msgid "" "Besides the default client-side based sessions, if you want to handle " "sessions on the server-side instead, there are several Flask extensions " "that support this." msgstr "" -#: ../../quickstart.rst:864 +#: ../../quickstart.rst:884 msgid "Message Flashing" msgstr "" -#: ../../quickstart.rst:866 +#: ../../quickstart.rst:886 msgid "" "Good applications and user interfaces are all about feedback. If the " "user does not get enough feedback they will probably end up hating the " @@ -942,7 +954,7 @@ msgid "" "layout template to expose the message." msgstr "" -#: ../../quickstart.rst:874 +#: ../../quickstart.rst:894 msgid "" "To flash a message use the :func:`~flask.flash` method, to get hold of " "the messages you can use :func:`~flask.get_flashed_messages` which is " @@ -950,11 +962,11 @@ msgid "" "example." msgstr "" -#: ../../quickstart.rst:880 +#: ../../quickstart.rst:900 msgid "Logging" msgstr "" -#: ../../quickstart.rst:884 +#: ../../quickstart.rst:904 msgid "" "Sometimes you might be in a situation where you deal with data that " "should be correct, but actually is not. For example you may have some " @@ -965,33 +977,33 @@ msgid "" "and the code has to continue working." msgstr "" -#: ../../quickstart.rst:892 +#: ../../quickstart.rst:912 msgid "" "You may still want to log that something fishy happened. This is where " "loggers come in handy. As of Flask 0.3 a logger is preconfigured for you" " to use." msgstr "" -#: ../../quickstart.rst:896 +#: ../../quickstart.rst:916 msgid "Here are some example log calls::" msgstr "" -#: ../../quickstart.rst:902 +#: ../../quickstart.rst:922 msgid "" "The attached :attr:`~flask.Flask.logger` is a standard logging " ":class:`~logging.Logger`, so head over to the official :mod:`logging` " "docs for more information." msgstr "" -#: ../../quickstart.rst:906 +#: ../../quickstart.rst:926 msgid "See :doc:`errorhandling`." msgstr "" -#: ../../quickstart.rst:910 +#: ../../quickstart.rst:930 msgid "Hooking in WSGI Middleware" msgstr "" -#: ../../quickstart.rst:912 +#: ../../quickstart.rst:932 msgid "" "To add WSGI middleware to your Flask application, wrap the application's " "``wsgi_app`` attribute. For example, to apply Werkzeug's " @@ -999,32 +1011,40 @@ msgid "" "behind Nginx:" msgstr "" -#: ../../quickstart.rst:922 +#: ../../quickstart.rst:942 msgid "" "Wrapping ``app.wsgi_app`` instead of ``app`` means that ``app`` still " "points at your Flask application, not at the middleware, so you can " "continue to use and configure ``app`` directly." msgstr "" -#: ../../quickstart.rst:927 +#: ../../quickstart.rst:947 msgid "Using Flask Extensions" msgstr "" -#: ../../quickstart.rst:929 +#: ../../quickstart.rst:949 msgid "" "Extensions are packages that help you accomplish common tasks. For " "example, Flask-SQLAlchemy provides SQLAlchemy support that makes it " "simple and easy to use with Flask." msgstr "" -#: ../../quickstart.rst:933 +#: ../../quickstart.rst:953 msgid "For more on Flask extensions, see :doc:`extensions`." msgstr "" -#: ../../quickstart.rst:936 +#: ../../quickstart.rst:956 msgid "Deploying to a Web Server" msgstr "" -#: ../../quickstart.rst:938 +#: ../../quickstart.rst:958 msgid "Ready to deploy your new Flask app? See :doc:`deploying/index`." msgstr "" + +#~ msgid "" +#~ "Inside templates you also have access" +#~ " to the :class:`~flask.request`, " +#~ ":class:`~flask.session` and :class:`~flask.g` [#]_" +#~ " objects as well as the " +#~ ":func:`~flask.get_flashed_messages` function." +#~ msgstr "" diff --git a/docs/locales/zh_CN/LC_MESSAGES/reqcontext.po b/docs/locales/zh_CN/LC_MESSAGES/reqcontext.po index b6daabcce..c111a4f8f 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/reqcontext.po +++ b/docs/locales/zh_CN/LC_MESSAGES/reqcontext.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: rosekc \n" "Language-Team: zh_CN \n" @@ -28,18 +28,18 @@ msgid "" "runs during a request, the :data:`request` and :data:`session` proxies " "are accessed instead." msgstr "" -"在请求当中,请求上下文保持对请求层级的数据的追踪。相比在请求当中把请求对" -"象传递到每个函数当中,Flask 使用了 :data:`request` 与 :data:`session` 代理" -"对象来访问请求对象。" +"在请求当中,请求上下文保持对请求层级的数据的追踪。相比在请求当中把请求对象传递到每个函数当中,Flask 使用了 :data:`request` " +"与 :data:`session` 代理对象来访问请求对象。" #: ../../reqcontext.rst:11 +#, fuzzy msgid "" -"This is similar to the :doc:`/appcontext`, which keeps track of the " +"This is similar to :doc:`/appcontext`, which keeps track of the " "application-level data independent of a request. A corresponding " "application context is pushed when a request context is pushed." msgstr "" -"这与 :doc:`/appcontext` 类似,只不过应用上下文跟踪独立于请求的应用层级数据。" -"在请求上下文被推入线程局部栈时,对应的应用上下文也被推入。" +"这与 :doc:`/appcontext` " +"类似,只不过应用上下文跟踪独立于请求的应用层级数据。在请求上下文被推入线程局部栈时,对应的应用上下文也被推入。" #: ../../reqcontext.rst:17 msgid "Purpose of the Context" @@ -54,11 +54,9 @@ msgid "" "be considered global to that worker during that request. Flask uses the " "term *context local* for this." msgstr "" -"当 :class:`Flask` 应用处理请求,根据从 WSGI 服务器获取到的环境,创建出相应的 :" -"class:`Request` 对象。因为 *工作者* (根据不同的服务器可能为线" -"程,进程或协程)一次只能处理一个请求,在请求当中,请求数据可以认为" -"对工作者全局可见、Flask 用术语 *上下文局部变量(context local)* 来表示" -"这种设计。" +"当 :class:`Flask` 应用处理请求,根据从 WSGI 服务器获取到的环境,创建出相应的 :class:`Request` 对象。因为 " +"*工作者* (根据不同的服务器可能为线程,进程或协程)一次只能处理一个请求,在请求当中,请求数据可以认为对工作者全局可见、Flask 用术语 " +"*上下文局部变量(context local)* 来表示这种设计。" #: ../../reqcontext.rst:26 msgid "" @@ -67,22 +65,22 @@ msgid "" "request will have access to the :data:`request` proxy, which points to " "the request object for the current request." msgstr "" -"Flask 在处理请求时,会自动 *推入* 请求上下文。视图函数,错误处理钩" -"子函数与其他在请求当中运行的函数可以访问指向当前请求的请求对象代理对象 :" -"data:`request`。" +"Flask 在处理请求时,会自动 *推入* 请求上下文。视图函数,错误处理钩子函数与其他在请求当中运行的函数可以访问指向当前请求的请求对象代理对象" +" :data:`request`。" #: ../../reqcontext.rst:33 msgid "Lifetime of the Context" msgstr "上下文的生命周期" #: ../../reqcontext.rst:35 +#, fuzzy msgid "" "When a Flask application begins handling a request, it pushes a request " -"context, which also pushes an :doc:`/appcontext`. When the request ends " -"it pops the request context then the application context." +"context, which also pushes an :doc:`app context `. When the " +"request ends it pops the request context then the application context." msgstr "" -"当 Flask 应用开始处理请求时,推入请求上下文的同时也推入了 :doc:`/" -"appcontext`。当请求结束,会先弹出请求上下文,然后再弹出应用上下文。" +"当 Flask 应用开始处理请求时,推入请求上下文的同时也推入了 " +":doc:`/appcontext`。当请求结束,会先弹出请求上下文,然后再弹出应用上下文。" #: ../../reqcontext.rst:39 msgid "" @@ -91,16 +89,14 @@ msgid "" " have a different context stack and will not know about the request the " "parent thread was pointing to." msgstr "" -"每个线程(或者其他工作者类型)的上下文是独立的。:data:`request` 不能传入其" -"他线程,其他线程有不同的上下文栈,因此不会知道父线程会指向哪个请求。" +"每个线程(或者其他工作者类型)的上下文是独立的。:data:`request` " +"不能传入其他线程,其他线程有不同的上下文栈,因此不会知道父线程会指向哪个请求。" #: ../../reqcontext.rst:44 msgid "" "Context locals are implemented in Werkzeug. See :doc:`werkzeug:local` for" " more information on how this works internally." -msgstr "" -"上下文局部变量的实现在 Werkzeug 中。若要了解更多内部工作细节,参见 :doc:" -"`werkzeug:local`。" +msgstr "上下文局部变量的实现在 Werkzeug 中。若要了解更多内部工作细节,参见 :doc:`werkzeug:local`。" #: ../../reqcontext.rst:49 msgid "Manually Push a Context" @@ -110,9 +106,7 @@ msgstr "手动推入上下文" msgid "" "If you try to access :data:`request`, or anything that uses it, outside a" " request context, you'll get this error message:" -msgstr "" -"如果要在应用上下文之外的地方试图去获取或者使用依赖 :data:`request` 的任何东西," -"有可能会收到这样的错误信息:" +msgstr "如果要在应用上下文之外的地方试图去获取或者使用依赖 :data:`request` 的任何东西,有可能会收到这样的错误信息:" #: ../../reqcontext.rst:62 msgid "" @@ -123,27 +117,23 @@ msgid "" "that runs in the block will have access to :data:`request`, populated " "with your test data. ::" msgstr "" -"这通常只会在测试需要活动请求的代码时候发生。其中一个方法是使用 :meth:" -"`test client ` 来模拟一个完整请求。或者可以在 ``with`` " -"块使用 :meth:`~Flask.test_request_context`,所有在块中运行的代码将会可以访" -"问由测试数据生成的 :data:`request`。 ::" +"这通常只会在测试需要活动请求的代码时候发生。其中一个方法是使用 :meth:`test client ` " +"来模拟一个完整请求。或者可以在 ``with`` 块使用 " +":meth:`~Flask.test_request_context`,所有在块中运行的代码将会可以访问由测试数据生成的 " +":data:`request`。 ::" #: ../../reqcontext.rst:77 msgid "" "If you see that error somewhere else in your code not related to testing," " it most likely indicates that you should move that code into a view " "function." -msgstr "" -"如果你在测试应用以外场景遇到这个错误,绝大多数情况下意味着这些代码应该转移" -"到视图函数下。" +msgstr "如果你在测试应用以外场景遇到这个错误,绝大多数情况下意味着这些代码应该转移到视图函数下。" #: ../../reqcontext.rst:81 msgid "" "For information on how to use the request context from the interactive " "Python shell, see :doc:`/shell`." -msgstr "" -"了解更多如何在 Python 交互式命令行中使用请求上下文的信息,参见 :doc:`/" -"shell`。" +msgstr "了解更多如何在 Python 交互式命令行中使用请求上下文的信息,参见 :doc:`/shell`。" #: ../../reqcontext.rst:86 msgid "How the Context Works" @@ -158,10 +148,9 @@ msgid "" "proxies that depend on them are available and point at information from " "the top context on the stack." msgstr "" -"在处理每个请求时,都会调用 :meth:`Flask.wsgi_app` 方法。它在请求中控制上下" -"文。具体来说,存储请求上下文和应用上下文的数据结构为栈,分别为 :data:" -"`_request_ctx_stack` 以及 :data:`_app_ctx_stack`。当上下文被推入栈,依赖栈" -"的代理对象变得可用,指向在栈顶的上下文。" +"在处理每个请求时,都会调用 :meth:`Flask.wsgi_app` " +"方法。它在请求中控制上下文。具体来说,存储请求上下文和应用上下文的数据结构为栈,分别为 :data:`_request_ctx_stack` 以及" +" :data:`_app_ctx_stack`。当上下文被推入栈,依赖栈的代理对象变得可用,指向在栈顶的上下文。" #: ../../reqcontext.rst:95 msgid "" @@ -172,10 +161,10 @@ msgid "" " and :data:`session` proxies are available to the original thread " "handling the request." msgstr "" -"当请求开始,将创建并推入 :class:`~ctx.RequestContext` 对象。如果此时应" -"用上下文不在上下文栈的顶部,将先创建 :class:`~ctx.AppContext`。当这些" -"上下文被推入,代理对象 :data:`current_app`、:data:`g`、:data:`request` 以" -"及 :data:`session` 在处理请求的线程变得可用。" +"当请求开始,将创建并推入 :class:`~ctx.RequestContext` 对象。如果此时应用上下文不在上下文栈的顶部,将先创建 " +":class:`~ctx.AppContext`。当这些上下文被推入,代理对象 " +":data:`current_app`、:data:`g`、:data:`request` 以及 :data:`session` " +"在处理请求的线程变得可用。" #: ../../reqcontext.rst:102 msgid "" @@ -183,10 +172,7 @@ msgid "" "the proxies during a request. While this is not a common pattern, it can " "be used in advanced applications to, for example, do internal redirects " "or chain different applications together." -msgstr "" -"因为上下文对象存放在栈中,在请求中,其他上下文对象推入时可能会改变代理" -"对象的指向。尽管这不是常见的设计模式,但它可以让应用能够内部重定向或者" -"将不同应用串联在一起。" +msgstr "因为上下文对象存放在栈中,在请求中,其他上下文对象推入时可能会改变代理对象的指向。尽管这不是常见的设计模式,但它可以让应用能够内部重定向或者将不同应用串联在一起。" #: ../../reqcontext.rst:107 msgid "" @@ -196,10 +182,9 @@ msgid "" "and :meth:`~Flask.teardown_appcontext` functions are executed. These " "execute even if an unhandled exception occurred during dispatch." msgstr "" -"当请求被分配到视图函数,生成并发送响应,请求上下文先被弹出,然后应用上下文" -"也被弹出。在上下文被弹出前,函数 :meth:`~Flask.teardown_request` 以及 :" -"meth:`~Flask.teardown_appcontext` 会被执行。即使在请求被分配过程中有未处理" -"的请求抛出,这些函数也会被执行。" +"当请求被分配到视图函数,生成并发送响应,请求上下文先被弹出,然后应用上下文也被弹出。在上下文被弹出前,函数 " +":meth:`~Flask.teardown_request` 以及 :meth:`~Flask.teardown_appcontext` " +"会被执行。即使在请求被分配过程中有未处理的请求抛出,这些函数也会被执行。" #: ../../reqcontext.rst:117 msgid "Callbacks and Errors" @@ -210,18 +195,14 @@ msgid "" "Flask dispatches a request in multiple stages which can affect the " "request, response, and how errors are handled. The contexts are active " "during all of these stages." -msgstr "" -"Flask 在不同阶段中会分配请求,这会影响请求、响应以及错误处理。在这些阶段" -"中,上下文处于可用状态。" +msgstr "Flask 在不同阶段中会分配请求,这会影响请求、响应以及错误处理。在这些阶段中,上下文处于可用状态。" #: ../../reqcontext.rst:123 msgid "" "A :class:`Blueprint` can add handlers for these events that are specific " "to the blueprint. The handlers for a blueprint will run if the blueprint " "owns the route that matches the request." -msgstr "" -":class:`Blueprint` 可以为这些事件添加蓝图专属的钩子函数。当蓝图所属的路由" -"匹配上请求,那么蓝图内的钩子函数将被执行。" +msgstr ":class:`Blueprint` 可以为这些事件添加蓝图专属的钩子函数。当蓝图所属的路由匹配上请求,那么蓝图内的钩子函数将被执行。" #: ../../reqcontext.rst:127 msgid "" @@ -230,18 +211,15 @@ msgid "" "skipped. The return value is treated as the response and the view " "function is not called." msgstr "" -"在每个请求前,会调用 :meth:`~Flask.before_request` 函数。如果其中的一个函" -"数返回了值,那么其他函数会被跳过执行。返回值会当作响应,视图函数不会被调" -"用。" +"在每个请求前,会调用 :meth:`~Flask.before_request` " +"函数。如果其中的一个函数返回了值,那么其他函数会被跳过执行。返回值会当作响应,视图函数不会被调用。" #: ../../reqcontext.rst:132 msgid "" "If the :meth:`~Flask.before_request` functions did not return a response," " the view function for the matched route is called and returns a " "response." -msgstr "" -"如果 :meth:`~Flask.before_request` 函数不返回响应,被路由匹配的视图函" -"数将被调用,返回请求。" +msgstr "如果 :meth:`~Flask.before_request` 函数不返回响应,被路由匹配的视图函数将被调用,返回请求。" #: ../../reqcontext.rst:136 msgid "" @@ -249,8 +227,8 @@ msgid "" "and passed to the :meth:`~Flask.after_request` functions. Each function " "returns a modified or new response object." msgstr "" -"视图函数返回的值会被转换成实际的响应对象,然后传递到 :meth:`~Flask." -"after_request` 函数。每个函数返回一个被修改的或者是新的响应对象。" +"视图函数返回的值会被转换成实际的响应对象,然后传递到 :meth:`~Flask.after_request` " +"函数。每个函数返回一个被修改的或者是新的响应对象。" #: ../../reqcontext.rst:140 msgid "" @@ -259,9 +237,8 @@ msgid "" "functions. These functions are called even if an unhandled exception was " "raised at any point above." msgstr "" -"当响应被返回,在弹出上下文的过程中,会调用 :meth:`~Flask." -"teardown_request` 和 :meth:`~Flask.teardown_appcontext` 函数。即使内部有一" -"个未处理的异常抛出,这些函数也会被执行。" +"当响应被返回,在弹出上下文的过程中,会调用 :meth:`~Flask.teardown_request` 和 " +":meth:`~Flask.teardown_appcontext` 函数。即使内部有一个未处理的异常抛出,这些函数也会被执行。" #: ../../reqcontext.rst:145 msgid "" @@ -272,10 +249,9 @@ msgid "" "Internal Server Error`` response. The teardown functions are still " "called, and are passed the exception object." msgstr "" -"如果异常在清理(teardown)函数中抛出,Flask 会尝试使用 :meth:`~Flask." -"errorhandler` 函数去处理异常,返回响应。如果没有错误钩子函数,或者钩子函数" -"本身抛出了异常,Flask 返回了通用的 ``500 Internal Server Error`` 响" -"应。清理函数一样会调用,而且会传入异常对象。" +"如果异常在清理(teardown)函数中抛出,Flask 会尝试使用 :meth:`~Flask.errorhandler` " +"函数去处理异常,返回响应。如果没有错误钩子函数,或者钩子函数本身抛出了异常,Flask 返回了通用的 ``500 Internal Server " +"Error`` 响应。清理函数一样会调用,而且会传入异常对象。" #: ../../reqcontext.rst:152 msgid "" @@ -284,9 +260,8 @@ msgid "" "allows the development server to present the interactive debugger with " "the traceback." msgstr "" -"在 debug 模式开启的时候,未处理的异常不会被转换为 ``500`` 响应,而是传递" -"给 WSGI 服务器。这让开发服务器可以展示带有异常跟踪(trackback)的交互式" -"调试器。" +"在 debug 模式开启的时候,未处理的异常不会被转换为 ``500`` 响应,而是传递给 WSGI " +"服务器。这让开发服务器可以展示带有异常跟踪(trackback)的交互式调试器。" #: ../../reqcontext.rst:159 msgid "Teardown Callbacks" @@ -301,11 +276,7 @@ msgid "" " parts of the request dispatch have run first. Be sure to write these " "functions in a way that does not depend on other callbacks and will not " "fail." -msgstr "" -"清理钩子函数独立于请求分配,而是在上下文被弹出的时候才调用。当在请求分配的" -"过程中,或者在手动推入的的上下文中有未捕抓的异常,这些函数依然会被调用。这" -"意味着不会保证在请求分配的每一部分都会首先执行。确保在编写这些函数的时候不" -"要依赖其他钩子函数,不要假设函数不会失败。" +msgstr "清理钩子函数独立于请求分配,而是在上下文被弹出的时候才调用。当在请求分配的过程中,或者在手动推入的的上下文中有未捕抓的异常,这些函数依然会被调用。这意味着不会保证在请求分配的每一部分都会首先执行。确保在编写这些函数的时候不要依赖其他钩子函数,不要假设函数不会失败。" #: ../../reqcontext.rst:169 msgid "" @@ -314,9 +285,8 @@ msgid "" "Use the :meth:`~Flask.test_client` as a ``with`` block to preserve the " "contexts until the ``with`` block exits." msgstr "" -"在测试的过程中,在请求结束的时候推迟弹出上下文是一种很有用的手段,它可以让" -"测试函数访问上下文中的数据。在 ``with`` 块中使用 :meth:`~Flask." -"test_client` 来让上下文在离开 ``with`` 块前保留。" +"在测试的过程中,在请求结束的时候推迟弹出上下文是一种很有用的手段,它可以让测试函数访问上下文中的数据。在 ``with`` 块中使用 " +":meth:`~Flask.test_client` 来让上下文在离开 ``with`` 块前保留。" #: ../../reqcontext.rst:203 msgid "Signals" @@ -332,17 +302,13 @@ msgstr "如果 :data:`~signals.signals_available` 为真,下列信号将被发 msgid "" ":data:`request_started` is sent before the :meth:`~Flask.before_request` " "functions are called." -msgstr "" -"在 :meth:`~Flask.before_request` 被调用前,:data:`request_started` 信号会" -"被发送。" +msgstr "在 :meth:`~Flask.before_request` 被调用前,:data:`request_started` 信号会被发送。" #: ../../reqcontext.rst:211 msgid "" ":data:`request_finished` is sent after the :meth:`~Flask.after_request` " "functions are called." -msgstr "" -"在 :meth:`~Flask.after_request` 被调用前,:data:`request_finished` 信号会" -"被发送。" +msgstr "在 :meth:`~Flask.after_request` 被调用前,:data:`request_finished` 信号会被发送。" #: ../../reqcontext.rst:214 msgid "" @@ -350,8 +316,8 @@ msgid "" "handled, but before an :meth:`~Flask.errorhandler` is looked up or " "called." msgstr "" -"当异常开始处理时,:data:`got_request_exception` 信号会在 :meth:`~Flask." -"errorhandler` 被查看或调用前被发送。" +"当异常开始处理时,:data:`got_request_exception` 信号会在 :meth:`~Flask.errorhandler` " +"被查看或调用前被发送。" #: ../../reqcontext.rst:218 msgid "" @@ -370,9 +336,7 @@ msgid "" "At the end of a request, the request context is popped and all data " "associated with it is destroyed. If an error occurs during development, " "it is useful to delay destroying the data for debugging purposes." -msgstr "" -"在请求结束时,上下文会被弹出,所有与上下文相关的数据会被销毁。如果在开发环" -"境中有错误发生,推迟销毁上下文数据对调试来说非常有用。" +msgstr "在请求结束时,上下文会被弹出,所有与上下文相关的数据会被销毁。如果在开发环境中有错误发生,推迟销毁上下文数据对调试来说非常有用。" #: ../../reqcontext.rst:229 msgid "" @@ -389,16 +353,14 @@ msgid "" ":data:`PRESERVE_CONTEXT_ON_EXCEPTION` config. As described above, it " "defaults to ``True`` in the development environment." msgstr "" -"这一行为能被 :data:`PRESERVE_CONTEXT_ON_EXCEPTION` 设置项所控制。如上文所" -"述。在开发环境中默认设置为 ``True``。" +"这一行为能被 :data:`PRESERVE_CONTEXT_ON_EXCEPTION` 设置项所控制。如上文所述。在开发环境中默认设置为 " +"``True``。" #: ../../reqcontext.rst:237 msgid "" "Do not enable :data:`PRESERVE_CONTEXT_ON_EXCEPTION` in production, as it " "will cause your application to leak memory on exceptions." -msgstr "" -"不要在生产环境中开启 :data:`PRESERVE_CONTEXT_ON_EXCEPTION`,因为这会让应用" -"在出现异常时内存泄露。" +msgstr "不要在生产环境中开启 :data:`PRESERVE_CONTEXT_ON_EXCEPTION`,因为这会让应用在出现异常时内存泄露。" #: ../../reqcontext.rst:244 msgid "Notes On Proxies" @@ -411,39 +373,32 @@ msgid "" " the unique object bound to each worker behind the scenes as described on" " this page." msgstr "" -"一些 Flask 提供的对象,是其他对象的代理。在每个工作线程中,代理对象会以" -"相同的方式被访问。在内部实现中,代理对象指向绑定到工作者的唯一的对象。细" -"节如本页所述。" +"一些 Flask " +"提供的对象,是其他对象的代理。在每个工作线程中,代理对象会以相同的方式被访问。在内部实现中,代理对象指向绑定到工作者的唯一的对象。细节如本页所述。" #: ../../reqcontext.rst:251 msgid "" "Most of the time you don't have to care about that, but there are some " "exceptions where it is good to know that this object is actually a proxy:" -msgstr "" -"大多数时候,这些细节无需担心。但有些时候最好还是知道这个对象实际上是一个代" -"理:" +msgstr "大多数时候,这些细节无需担心。但有些时候最好还是知道这个对象实际上是一个代理:" #: ../../reqcontext.rst:254 msgid "" "The proxy objects cannot fake their type as the actual object types. If " "you want to perform instance checks, you have to do that on the object " "being proxied." -msgstr "" -"代理对象不能冒充实际指向的对象类型。如果要进行实例检查,应当要在被代理的对" -"象本身进行检查。" +msgstr "代理对象不能冒充实际指向的对象类型。如果要进行实例检查,应当要在被代理的对象本身进行检查。" #: ../../reqcontext.rst:257 msgid "" "The reference to the proxied object is needed in some situations, such as" " sending :doc:`signals` or passing data to a background thread." -msgstr "" -"在某些要使用被代理对象的引用的时候,如发送 :doc:`signals` 或者向后台线程传" -"递数据。" +msgstr "在某些要使用被代理对象的引用的时候,如发送 :doc:`signals` 或者向后台线程传递数据。" #: ../../reqcontext.rst:261 msgid "" "If you need to access the underlying object that is proxied, use the " ":meth:`~werkzeug.local.LocalProxy._get_current_object` method::" msgstr "" -"如果需要访问在底层被代理的对象,使用 :meth:`~werkzeug.local.LocalProxy." -"_get_current_object` 这个方法: ::" +"如果需要访问在底层被代理的对象,使用 :meth:`~werkzeug.local.LocalProxy._get_current_object`" +" 这个方法: ::" diff --git a/docs/locales/zh_CN/LC_MESSAGES/security.po b/docs/locales/zh_CN/LC_MESSAGES/security.po index b3755c1b9..fc86a69f4 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/security.po +++ b/docs/locales/zh_CN/LC_MESSAGES/security.po @@ -7,16 +7,16 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: 2021-06-15 17:09+0800\n" +"Last-Translator: kylin \n" +"Language: zh_CN\n" "Language-Team: zh_CN \n" +"Plural-Forms: nplurals=1; plural=0\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.9.1\n" -"Last-Translator: kylin \n" -"Language: zh_CN\n" -"X-Generator: Poedit 3.0\n" #: ../../security.rst:2 msgid "Security Considerations" @@ -24,12 +24,11 @@ msgstr "安全注意事项" #: ../../security.rst:4 msgid "" -"Web applications usually face all kinds of security problems and it's very hard " -"to get everything right. Flask tries to solve a few of these things for you, " -"but there are a couple more you have to take care of yourself." -msgstr "" -"Web 应用通常会面临各种安全问题,很难把他们全都处理好。Flask 试图为你解决其" -"中的一些问题,但还有很多需要你自己处理。" +"Web applications usually face all kinds of security problems and it's " +"very hard to get everything right. Flask tries to solve a few of these " +"things for you, but there are a couple more you have to take care of " +"yourself." +msgstr "Web 应用通常会面临各种安全问题,很难把他们全都处理好。Flask 试图为你解决其中的一些问题,但还有很多需要你自己处理。" #: ../../security.rst:11 msgid "Cross-Site Scripting (XSS)" @@ -37,25 +36,25 @@ msgstr "跨站脚本攻击(XSS)" #: ../../security.rst:13 msgid "" -"Cross site scripting is the concept of injecting arbitrary HTML (and with it " -"JavaScript) into the context of a website. To remedy this, developers have to " -"properly escape text so that it cannot include arbitrary HTML tags. For more " -"information on that have a look at the Wikipedia article on `Cross-Site " -"Scripting `_." +"Cross site scripting is the concept of injecting arbitrary HTML (and with" +" it JavaScript) into the context of a website. To remedy this, " +"developers have to properly escape text so that it cannot include " +"arbitrary HTML tags. For more information on that have a look at the " +"Wikipedia article on `Cross-Site Scripting `_." msgstr "" -"跨站脚本攻击是指将恶意的 HTML(以及附带的 JavaScript)代码注入到网站的环境中。" -"为了解决这个问题,开发人员必须正确地转义文本,使其无法包含恶意的 HTML 标签。更" -"多信息请看维基百科上的文章 `Cross-Site Scripting `_。" +"跨站脚本攻击是指将恶意的 HTML(以及附带的 " +"JavaScript)代码注入到网站的环境中。为了解决这个问题,开发人员必须正确地转义文本,使其无法包含恶意的 HTML " +"标签。更多信息请看维基百科上的文章 `Cross-Site Scripting `_。" #: ../../security.rst:20 msgid "" -"Flask configures Jinja2 to automatically escape all values unless explicitly " -"told otherwise. This should rule out all XSS problems caused in templates, but " -"there are still other places where you have to be careful:" -msgstr "" -"Flask 配置了 Jinja2 自动转义所有值,除非显式指明不转义。这应该可以排除所有由模板" -"引起的 XSS 问题,但仍有其他地方需要注意:" +"Flask configures Jinja2 to automatically escape all values unless " +"explicitly told otherwise. This should rule out all XSS problems caused " +"in templates, but there are still other places where you have to be " +"careful:" +msgstr "Flask 配置了 Jinja2 自动转义所有值,除非显式指明不转义。这应该可以排除所有由模板引起的 XSS 问题,但仍有其他地方需要注意:" #: ../../security.rst:25 msgid "generating HTML without the help of Jinja2" @@ -69,66 +68,62 @@ msgstr "在用户提交的数据上调用 :class:`~flask.Markup`" msgid "" "sending out HTML from uploaded files, never do that, use the ``Content-" "Disposition: attachment`` header to prevent that problem." -msgstr "" -"发送上传的 HTML 文件,千万不要这样做,应该使用 ``Content-Disposition: " -"attachment`` 头部来避免这个问题。" +msgstr "发送上传的 HTML 文件,千万不要这样做,应该使用 ``Content-Disposition: attachment`` 头部来避免这个问题。" #: ../../security.rst:29 msgid "" -"sending out textfiles from uploaded files. Some browsers are using content-" -"type guessing based on the first few bytes so users could trick a browser to " -"execute HTML." -msgstr "" -"发送上传的文本文件。一些浏览器会基于文件开头的几个字节推测文件的内容类型,因此用" -"户可以欺骗浏览器执行 HTML。" +"sending out textfiles from uploaded files. Some browsers are using " +"content-type guessing based on the first few bytes so users could trick a" +" browser to execute HTML." +msgstr "发送上传的文本文件。一些浏览器会基于文件开头的几个字节推测文件的内容类型,因此用户可以欺骗浏览器执行 HTML。" #: ../../security.rst:33 msgid "" -"Another thing that is very important are unquoted attributes. While Jinja2 can " -"protect you from XSS issues by escaping HTML, there is one thing it cannot " -"protect you from: XSS by attribute injection. To counter this possible attack " -"vector, be sure to always quote your attributes with either double or single " -"quotes when using Jinja expressions in them:" +"Another thing that is very important are unquoted attributes. While " +"Jinja2 can protect you from XSS issues by escaping HTML, there is one " +"thing it cannot protect you from: XSS by attribute injection. To counter" +" this possible attack vector, be sure to always quote your attributes " +"with either double or single quotes when using Jinja expressions in them:" msgstr "" -"另外值得注意的是未经引号包裹的属性。虽然 Jinja2 可以通过转义 HTML 避免 XSS 问题," -"但无法避免通过属性注入的 XSS。为了对付这种可能存在的攻击手段,在属性中使用 " -"Jinja 表达式时,请保证属性值始终被包括在双引号或单引号内:" +"另外值得注意的是未经引号包裹的属性。虽然 Jinja2 可以通过转义 HTML 避免 XSS 问题,但无法避免通过属性注入的 " +"XSS。为了对付这种可能存在的攻击手段,在属性中使用 Jinja 表达式时,请保证属性值始终被包括在双引号或单引号内:" #: ../../security.rst:43 msgid "" -"Why is this necessary? Because if you would not be doing that, an attacker " -"could easily inject custom JavaScript handlers. For example an attacker could " -"inject this piece of HTML+JavaScript:" +"Why is this necessary? Because if you would not be doing that, an " +"attacker could easily inject custom JavaScript handlers. For example an " +"attacker could inject this piece of HTML+JavaScript:" msgstr "" -"为什么必须这样做?因为如果不这样做,攻击者可以轻易注入定制的 JavaScript 事件处理" -"器。例如,攻击者可以注入以下 HTML + JavaScript 代码:" +"为什么必须这样做?因为如果不这样做,攻击者可以轻易注入定制的 JavaScript 事件处理器。例如,攻击者可以注入以下 HTML + " +"JavaScript 代码:" #: ../../security.rst:51 msgid "" -"When the user would then move with the mouse over the input, the cookie would " -"be presented to the user in an alert window. But instead of showing the cookie " -"to the user, a good attacker might also execute any other JavaScript code. In " -"combination with CSS injections the attacker might even make the element fill " -"out the entire page so that the user would just have to have the mouse anywhere " -"on the page to trigger the attack." +"When the user would then move with the mouse over the input, the cookie " +"would be presented to the user in an alert window. But instead of " +"showing the cookie to the user, a good attacker might also execute any " +"other JavaScript code. In combination with CSS injections the attacker " +"might even make the element fill out the entire page so that the user " +"would just have to have the mouse anywhere on the page to trigger the " +"attack." msgstr "" -"当用户将鼠标移到输入框时,cookie 信息就会显示在弹出的警告窗口中。 一个聪明的攻击" -"者可能不会直接向用户显示 cookie 信息,而是执行其他的 JavaScript 代码。 结合 CSS " -"注入,攻击者甚至可能使该元素填满整个页面,这样用户将鼠标放在页面的任何位置都会触" -"发攻击。" +"当用户将鼠标移到输入框时,cookie 信息就会显示在弹出的警告窗口中。 一个聪明的攻击者可能不会直接向用户显示 cookie " +"信息,而是执行其他的 JavaScript 代码。 结合 CSS " +"注入,攻击者甚至可能使该元素填满整个页面,这样用户将鼠标放在页面的任何位置都会触发攻击。" #: ../../security.rst:58 msgid "" "There is one class of XSS issues that Jinja's escaping does not protect " -"against. The ``a`` tag's ``href`` attribute can contain a `javascript:` URI, " -"which the browser will execute when clicked if not secured properly." +"against. The ``a`` tag's ``href`` attribute can contain a `javascript:` " +"URI, which the browser will execute when clicked if not secured properly." msgstr "" -"有一类 XSS 问题,Jinja 的转义并不能防止。``a`` 标签的 ``href`` 属性可以包含一" -"个 `javascript:` URI,如果没有采取合理的安全措施,在点击时浏览器就会执行。" +"有一类 XSS 问题,Jinja 的转义并不能防止。``a`` 标签的 ``href`` 属性可以包含一个 `javascript:` " +"URI,如果没有采取合理的安全措施,在点击时浏览器就会执行。" #: ../../security.rst:67 msgid "" -"To prevent this, you'll need to set the :ref:`security-csp` response header." +"To prevent this, you'll need to set the :ref:`security-csp` response " +"header." msgstr "为了防止这种问题发生,你需要设置 :ref:`security-csp` 响应头部。" #: ../../security.rst:70 @@ -137,68 +132,60 @@ msgstr "跨站请求伪造(CSRF)" #: ../../security.rst:72 msgid "" -"Another big problem is CSRF. This is a very complex topic and I won't outline " -"it here in detail just mention what it is and how to theoretically prevent it." -msgstr "" -"另一个大问题是跨站请求伪造。这是一个很复杂的话题,细节不在这里赘述,只谈谈它是" -"什么以及如何在理论上避免这个问题。" +"Another big problem is CSRF. This is a very complex topic and I won't " +"outline it here in detail just mention what it is and how to " +"theoretically prevent it." +msgstr "另一个大问题是跨站请求伪造。这是一个很复杂的话题,细节不在这里赘述,只谈谈它是什么以及如何在理论上避免这个问题。" #: ../../security.rst:76 msgid "" -"If your authentication information is stored in cookies, you have implicit " -"state management. The state of \"being logged in\" is controlled by a cookie, " -"and that cookie is sent with each request to a page. Unfortunately that " -"includes requests triggered by 3rd party sites. If you don't keep that in " -"mind, some people might be able to trick your application's users with social " -"engineering to do stupid things without them knowing." +"If your authentication information is stored in cookies, you have " +"implicit state management. The state of \"being logged in\" is " +"controlled by a cookie, and that cookie is sent with each request to a " +"page. Unfortunately that includes requests triggered by 3rd party sites." +" If you don't keep that in mind, some people might be able to trick your" +" application's users with social engineering to do stupid things without " +"them knowing." msgstr "" -"如果你的认证信息存储在 cookie 中,你就有了隐式状态管理。“登录”的状态是由一个 " -"cookie 控制的,对每个页面的请求都会带上这个 cookie。不幸的是,由第三方网站发起的" -"请求也遵循同样的机制。如果你不牢记这一点,有人可能会用社交工程欺骗应用程序的用" -"户,让他们在不知情的情况下做一些愚蠢的事情。" +"如果你的认证信息存储在 cookie 中,你就有了隐式状态管理。“登录”的状态是由一个 cookie 控制的,对每个页面的请求都会带上这个 " +"cookie。不幸的是,由第三方网站发起的请求也遵循同样的机制。如果你不牢记这一点,有人可能会用社交工程欺骗应用程序的用户,让他们在不知情的情况下做一些愚蠢的事情。" #: ../../security.rst:84 msgid "" -"Say you have a specific URL that, when you sent ``POST`` requests to will " -"delete a user's profile (say ``http://example.com/user/delete``). If an " -"attacker now creates a page that sends a post request to that page with some " -"JavaScript they just have to trick some users to load that page and their " -"profiles will end up being deleted." +"Say you have a specific URL that, when you sent ``POST`` requests to will" +" delete a user's profile (say ``http://example.com/user/delete``). If an" +" attacker now creates a page that sends a post request to that page with " +"some JavaScript they just have to trick some users to load that page and " +"their profiles will end up being deleted." msgstr "" "假设你有一个特定的 URL,当你发送 ``POST`` 请求时会删除一个用户的资料(例如 " -"``http://example.com/user/delete``)。 如果攻击者现在创建了一个页面可以通过一些 " -"JavaScript 代码向你的特定 URL 发送 post 请求,只要欺骗用户来加载这个页面,用户资" -"料就会被删除了。" +"``http://example.com/user/delete``)。 如果攻击者现在创建了一个页面可以通过一些 JavaScript " +"代码向你的特定 URL 发送 post 请求,只要欺骗用户来加载这个页面,用户资料就会被删除了。" #: ../../security.rst:90 msgid "" -"Imagine you were to run Facebook with millions of concurrent users and someone " -"would send out links to images of little kittens. When users would go to that " -"page, their profiles would get deleted while they are looking at images of " -"fluffy cats." -msgstr "" -"想象一下有数百万并发用户的 Facebook,有人发出小猫咪图片的链接。 当用户访问该" -"页面看着毛茸茸的猫片时,他们的资料就被删除了。" +"Imagine you were to run Facebook with millions of concurrent users and " +"someone would send out links to images of little kittens. When users " +"would go to that page, their profiles would get deleted while they are " +"looking at images of fluffy cats." +msgstr "想象一下有数百万并发用户的 Facebook,有人发出小猫咪图片的链接。 当用户访问该页面看着毛茸茸的猫片时,他们的资料就被删除了。" #: ../../security.rst:95 msgid "" -"How can you prevent that? Basically for each request that modifies content on " -"the server you would have to either use a one-time token and store that in the " -"cookie **and** also transmit it with the form data. After receiving the data on " -"the server again, you would then have to compare the two tokens and ensure they " -"are equal." +"How can you prevent that? Basically for each request that modifies " +"content on the server you would have to either use a one-time token and " +"store that in the cookie **and** also transmit it with the form data. " +"After receiving the data on the server again, you would then have to " +"compare the two tokens and ensure they are equal." msgstr "" -"如何防止这种情况呢?基本思路是:每一个修改服务器内容的请求,必须使用一个" -"一次性令牌,并将其存储在 cookie 中,传输表单数据时带上它。服务器再次接收到数据" -"后,必须比较两个令牌,确保它们是相等的。" +"如何防止这种情况呢?基本思路是:每一个修改服务器内容的请求,必须使用一个一次性令牌,并将其存储在 cookie " +"中,传输表单数据时带上它。服务器再次接收到数据后,必须比较两个令牌,确保它们是相等的。" #: ../../security.rst:101 msgid "" -"Why does Flask not do that for you? The ideal place for this to happen is the " -"form validation framework, which does not exist in Flask." -msgstr "" -"为什么 Flask 不替你完成这个呢?因为这是表单验证框架要做的事,而 Flask 自身不包含" -"表单验证。" +"Why does Flask not do that for you? The ideal place for this to happen " +"is the form validation framework, which does not exist in Flask." +msgstr "为什么 Flask 不替你完成这个呢?因为这是表单验证框架要做的事,而 Flask 自身不包含表单验证。" #: ../../security.rst:107 msgid "JSON Security" @@ -206,24 +193,25 @@ msgstr "JSON 安全" #: ../../security.rst:109 msgid "" -"In Flask 0.10 and lower, :func:`~flask.jsonify` did not serialize top-level " -"arrays to JSON. This was because of a security vulnerability in ECMAScript 4." +"In Flask 0.10 and lower, :func:`~flask.jsonify` did not serialize top-" +"level arrays to JSON. This was because of a security vulnerability in " +"ECMAScript 4." msgstr "" "在 Flask 0.10 以及更低版本中,因为 ECMAScript 4 中的安全漏洞,:func:`~flask.jsonify` " "没有将顶层数组序列化为 JSON。" #: ../../security.rst:112 msgid "" -"ECMAScript 5 closed this vulnerability, so only extremely old browsers are " -"still vulnerable. All of these browsers have `other more serious " -"vulnerabilities `_, so this behavior was changed and :func:" -"`~flask.jsonify` now supports serializing arrays." +"ECMAScript 5 closed this vulnerability, so only extremely old browsers " +"are still vulnerable. All of these browsers have `other more serious " +"vulnerabilities " +"`_, so" +" this behavior was changed and :func:`~flask.jsonify` now supports " +"serializing arrays." msgstr "" -"ECMAScript 5 关闭了这个漏洞,所以只有非常老的浏览器仍然容易受到攻击,这些" -"浏览器还存在 `其他更严重的漏洞 `_,因而这个行为被改变了,:func:`~flask.jsonify` " -"现在支持序列化数组。" +"ECMAScript 5 关闭了这个漏洞,所以只有非常老的浏览器仍然容易受到攻击,这些浏览器还存在 `其他更严重的漏洞 " +"`_,因而这个行为被改变了,:func:`~flask.jsonify`" +" 现在支持序列化数组。" #: ../../security.rst:120 msgid "Security Headers" @@ -231,13 +219,13 @@ msgstr "安全头部" #: ../../security.rst:122 msgid "" -"Browsers recognize various response headers in order to control security. We " -"recommend reviewing each of the headers below for use in your application. The " -"`Flask-Talisman`_ extension can be used to manage HTTPS and the security " -"headers for you." +"Browsers recognize various response headers in order to control security." +" We recommend reviewing each of the headers below for use in your " +"application. The `Flask-Talisman`_ extension can be used to manage HTTPS " +"and the security headers for you." msgstr "" -"为了控制安全性,浏览器识别各种响应头部。我们建议你在应用程序中检查以下每种头" -"部,`Flask-Talisman`_ 扩展可用于管理 HTTPS 和安全头部。" +"为了控制安全性,浏览器识别各种响应头部。我们建议你在应用程序中检查以下每种头部,`Flask-Talisman`_ 扩展可用于管理 HTTPS " +"和安全头部。" #: ../../security.rst:130 msgid "HTTP Strict Transport Security (HSTS)" @@ -245,17 +233,17 @@ msgstr "HTTP 严格传输安全(HSTS)" #: ../../security.rst:132 msgid "" -"Tells the browser to convert all HTTP requests to HTTPS, preventing man-in-the-" -"middle (MITM) attacks. ::" +"Tells the browser to convert all HTTP requests to HTTPS, preventing man-" +"in-the-middle (MITM) attacks. ::" msgstr "指示浏览器把所有 HTTP 请求转为 HTTPS,防止中间人攻击(MITM)。" #: ../../security.rst:137 msgid "" -"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-" -"Security" +"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-" +"Transport-Security" msgstr "" -"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-" -"Security" +"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-" +"Transport-Security" #: ../../security.rst:142 msgid "Content Security Policy (CSP)" @@ -263,12 +251,10 @@ msgstr "内容安全策略(CSP)" #: ../../security.rst:144 msgid "" -"Tell the browser where it can load various types of resource from. This header " -"should be used whenever possible, but requires some work to define the correct " -"policy for your site. A very strict policy would be::" -msgstr "" -"告诉浏览器可以从哪里加载各种类型的资源。应当尽可能使用这个头部,但需要为网站定义" -"正确的策略。一个非常严格的策略是:" +"Tell the browser where it can load various types of resource from. This " +"header should be used whenever possible, but requires some work to define" +" the correct policy for your site. A very strict policy would be::" +msgstr "告诉浏览器可以从哪里加载各种类型的资源。应当尽可能使用这个头部,但需要为网站定义正确的策略。一个非常严格的策略是:" #: ../../security.rst:150 msgid "https://csp.withgoogle.com/docs/index.html" @@ -276,11 +262,11 @@ msgstr "https://csp.withgoogle.com/docs/index.html" #: ../../security.rst:151 msgid "" -"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-" -"Policy" +"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-" +"Security-Policy" msgstr "" -"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-" -"Policy" +"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-" +"Security-Policy" #: ../../security.rst:154 msgid "X-Content-Type-Options" @@ -288,17 +274,18 @@ msgstr "X-Content-Type-Options" #: ../../security.rst:156 msgid "" -"Forces the browser to honor the response content type instead of trying to " -"detect it, which can be abused to generate a cross-site scripting (XSS) " -"attack. ::" -msgstr "" -"强制浏览器接受响应的内容类型,而不是尝试检测它,防止被滥用而产生跨站脚本攻击(XSS)。" +"Forces the browser to honor the response content type instead of trying " +"to detect it, which can be abused to generate a cross-site scripting " +"(XSS) attack. ::" +msgstr "强制浏览器接受响应的内容类型,而不是尝试检测它,防止被滥用而产生跨站脚本攻击(XSS)。" #: ../../security.rst:162 msgid "" -"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options" +"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-" +"Options" msgstr "" -"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options" +"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-" +"Options" #: ../../security.rst:165 msgid "X-Frame-Options" @@ -307,166 +294,161 @@ msgstr "X-Frame-Options" #: ../../security.rst:167 msgid "" "Prevents external sites from embedding your site in an ``iframe``. This " -"prevents a class of attacks where clicks in the outer frame can be translated " -"invisibly to clicks on your page's elements. This is also known as " -"\"clickjacking\". ::" -msgstr "" -"防止外部网站将你的网站嵌入 ``iframe`` 中,可以避免一类攻击:对外框的点击无形地转" -"化为对你的页面元素的点击。这也被称为“点击劫持”。" +"prevents a class of attacks where clicks in the outer frame can be " +"translated invisibly to clicks on your page's elements. This is also " +"known as \"clickjacking\". ::" +msgstr "防止外部网站将你的网站嵌入 ``iframe`` 中,可以避免一类攻击:对外框的点击无形地转化为对你的页面元素的点击。这也被称为“点击劫持”。" #: ../../security.rst:174 msgid "https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options" msgstr "https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options" -#: ../../security.rst:177 -msgid "X-XSS-Protection" -msgstr "X-XSS-Protection" - #: ../../security.rst:179 -msgid "" -"The browser will try to prevent reflected XSS attacks by not loading the page " -"if the request contains something that looks like JavaScript and the response " -"contains the same data. ::" -msgstr "" -"如果请求中含有一些类似 JavaScript 代码的东西,且响应中包含相同的数据,浏览器将试" -"图通过不加载页面来防止反射式 XSS 攻击。" - -#: ../../security.rst:185 -msgid "https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection" -msgstr "" -"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection" - -#: ../../security.rst:191 msgid "Set-Cookie options" msgstr "Set-Cookie 选项" -#: ../../security.rst:193 +#: ../../security.rst:181 msgid "" "These options can be added to a ``Set-Cookie`` header to improve their " -"security. Flask has configuration options to set these on the session cookie. " -"They can be set on other cookies too." +"security. Flask has configuration options to set these on the session " +"cookie. They can be set on other cookies too." msgstr "" -"下面这些选项可以添加到 ``Set-Cookie`` 头部中以提高安全性。Flask 有配置选项可以将这" -"些设置在会话 cookie 或者其他 cookie 上。" +"下面这些选项可以添加到 ``Set-Cookie`` 头部中以提高安全性。Flask 有配置选项可以将这些设置在会话 cookie 或者其他 " +"cookie 上。" -#: ../../security.rst:197 +#: ../../security.rst:185 msgid "``Secure`` limits cookies to HTTPS traffic only." msgstr "``Secure`` 限制 cookies 只用于 HTTPS 流量。" -#: ../../security.rst:198 +#: ../../security.rst:186 msgid "" -"``HttpOnly`` protects the contents of cookies from being read with JavaScript." +"``HttpOnly`` protects the contents of cookies from being read with " +"JavaScript." msgstr "``HttpOnly`` 保护 cookies 内容不被 JavaScript 读取。" -#: ../../security.rst:200 +#: ../../security.rst:188 msgid "" -"``SameSite`` restricts how cookies are sent with requests from external sites. " -"Can be set to ``'Lax'`` (recommended) or ``'Strict'``. ``Lax`` prevents sending " -"cookies with CSRF-prone requests from external sites, such as submitting a " -"form. ``Strict`` prevents sending cookies with all external requests, including " -"following regular links." +"``SameSite`` restricts how cookies are sent with requests from external " +"sites. Can be set to ``'Lax'`` (recommended) or ``'Strict'``. ``Lax`` " +"prevents sending cookies with CSRF-prone requests from external sites, " +"such as submitting a form. ``Strict`` prevents sending cookies with all " +"external requests, including following regular links." msgstr "" -"``SameSite`` 限制 cookies 如何与外部网站的请求一起发送。可设置为 ``’Lax’``(推荐)" -"或 ``’Strict’``。``Lax`` 防止外部网站有 CSRF 请求倾向时(例如提交表单)发送 " -"cookies。``Strict`` 禁止所有外部请求发送 cookie,包括常规链接。" +"``SameSite`` 限制 cookies 如何与外部网站的请求一起发送。可设置为 ``’Lax’``(推荐)或 " +"``’Strict’``。``Lax`` 防止外部网站有 CSRF 请求倾向时(例如提交表单)发送 cookies。``Strict`` " +"禁止所有外部请求发送 cookie,包括常规链接。" -#: ../../security.rst:216 +#: ../../security.rst:204 msgid "" -"Specifying ``Expires`` or ``Max-Age`` options, will remove the cookie after the " -"given time, or the current time plus the age, respectively. If neither option " -"is set, the cookie will be removed when the browser is closed. ::" +"Specifying ``Expires`` or ``Max-Age`` options, will remove the cookie " +"after the given time, or the current time plus the age, respectively. If " +"neither option is set, the cookie will be removed when the browser is " +"closed. ::" msgstr "" -"指定 ``Expires`` 或 ``Max-Age`` 选项时,cookie 会在超过了给定的时间或当前时间加上" -"的期限之后被删除。如果两个选项都没有设置,cookie 将在浏览器关闭时被删除。" +"指定 ``Expires`` 或 ``Max-Age`` 选项时,cookie " +"会在超过了给定的时间或当前时间加上的期限之后被删除。如果两个选项都没有设置,cookie 将在浏览器关闭时被删除。" -#: ../../security.rst:223 +#: ../../security.rst:211 msgid "" -"For the session cookie, if :attr:`session.permanent ` " -"is set, then :data:`PERMANENT_SESSION_LIFETIME` is used to set the expiration. " -"Flask's default cookie implementation validates that the cryptographic " -"signature is not older than this value. Lowering this value may help mitigate " +"For the session cookie, if :attr:`session.permanent " +"` is set, then " +":data:`PERMANENT_SESSION_LIFETIME` is used to set the expiration. Flask's" +" default cookie implementation validates that the cryptographic signature" +" is not older than this value. Lowering this value may help mitigate " "replay attacks, where intercepted cookies can be sent at a later time. ::" msgstr "" -"对于会话 cookie,如果设置了 :attr:`session.permanent `," -"那么就用 :data:`PERMANENT_SESSION_LIFETIME` 设置到期时间,Flask 的" -"默认 cookie 实现会验证加密签名不超过这个值,降低此值有助于减少重复攻击,防止 " -"cookie 被拦截后还可以在一段时间内有效发送的漏洞。" +"对于会话 cookie,如果设置了 :attr:`session.permanent " +"`,那么就用 :data:`PERMANENT_SESSION_LIFETIME` " +"设置到期时间,Flask 的默认 cookie 实现会验证加密签名不超过这个值,降低此值有助于减少重复攻击,防止 cookie " +"被拦截后还可以在一段时间内有效发送的漏洞。" -#: ../../security.rst:241 +#: ../../security.rst:229 msgid "" -"Use :class:`itsdangerous.TimedSerializer` to sign and validate other cookie " -"values (or any values that need secure signatures)." -msgstr "" -"使用 :class:`itsdangerous.TimedSerializer` 来签名和验证其他 cookie 值(或任何需" -"要安全签名的值)。" +"Use :class:`itsdangerous.TimedSerializer` to sign and validate other " +"cookie values (or any values that need secure signatures)." +msgstr "使用 :class:`itsdangerous.TimedSerializer` 来签名和验证其他 cookie 值(或任何需要安全签名的值)。" -#: ../../security.rst:244 +#: ../../security.rst:232 msgid "https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies" msgstr "https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies" -#: ../../security.rst:245 +#: ../../security.rst:233 msgid "https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie" msgstr "https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie" -#: ../../security.rst:251 +#: ../../security.rst:239 msgid "HTTP Public Key Pinning (HPKP)" msgstr "HTTP 公钥锁定(HPKP)" -#: ../../security.rst:253 +#: ../../security.rst:241 msgid "" -"This tells the browser to authenticate with the server using only the specific " -"certificate key to prevent MITM attacks." +"This tells the browser to authenticate with the server using only the " +"specific certificate key to prevent MITM attacks." msgstr "它告诉浏览器只使用特定的证书密钥与服务器进行验证,以防止 MITM 攻击。" -#: ../../security.rst:257 +#: ../../security.rst:245 msgid "" -"Be careful when enabling this, as it is very difficult to undo if you set up or " -"upgrade your key incorrectly." +"Be careful when enabling this, as it is very difficult to undo if you set" +" up or upgrade your key incorrectly." msgstr "启用这个要小心,如果设置密钥或升级密钥不正确则难以撤销。" -#: ../../security.rst:260 +#: ../../security.rst:248 msgid "https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning" msgstr "https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning" -#: ../../security.rst:264 +#: ../../security.rst:252 msgid "Copy/Paste to Terminal" msgstr "复制/粘贴到终端" -#: ../../security.rst:266 +#: ../../security.rst:254 msgid "" -"Hidden characters such as the backspace character (``\\b``, ``^H``) can cause " -"text to render differently in HTML than how it is interpreted if `pasted into a " -"terminal `__." +"Hidden characters such as the backspace character (``\\b``, ``^H``) can " +"cause text to render differently in HTML than how it is interpreted if " +"`pasted into a terminal `__." msgstr "" -"隐藏的字符如退格符(``\\b``, ``^H``)会导致文本在 HTML 中的显示方式与 `粘贴到终" -"端 `__ 的呈现方式不同。" +"隐藏的字符如退格符(``\\b``, ``^H``)会导致文本在 HTML 中的显示方式与 `粘贴到终端 " +"`__ 的呈现方式不同。" -#: ../../security.rst:270 +#: ../../security.rst:258 msgid "" "For example, ``import y\\bose\\bm\\bi\\bt\\be\\b`` renders as ``import " -"yosemite`` in HTML, but the backspaces are applied when pasted into a terminal, " -"and it becomes ``import os``." +"yosemite`` in HTML, but the backspaces are applied when pasted into a " +"terminal, and it becomes ``import os``." msgstr "" "例如,``import y\\bose\\bm\\bi\\bt\\be\\b`` 在 HTML 中显示为 ``import " "yosemite``,但在粘贴到终端时退格符生效,变成 ``import os``." -#: ../../security.rst:274 +#: ../../security.rst:262 msgid "" -"If you expect users to copy and paste untrusted code from your site, such as " -"from comments posted by users on a technical blog, consider applying extra " -"filtering, such as replacing all ``\\b`` characters." -msgstr "" -"如果用户有可能从你的网站上复制和粘贴不受信任的代码,比如在技术博客上发布的评论," -"要考虑使用更多的过滤条件,例如替换所有 ``\\b`` 字符。" +"If you expect users to copy and paste untrusted code from your site, such" +" as from comments posted by users on a technical blog, consider applying " +"extra filtering, such as replacing all ``\\b`` characters." +msgstr "如果用户有可能从你的网站上复制和粘贴不受信任的代码,比如在技术博客上发布的评论,要考虑使用更多的过滤条件,例如替换所有 ``\\b`` 字符。" -#: ../../security.rst:282 +#: ../../security.rst:270 msgid "" "Most modern terminals will warn about and remove hidden characters when " "pasting, so this isn't strictly necessary. It's also possible to craft " -"dangerous commands in other ways that aren't possible to filter. Depending on " -"your site's use case, it may be good to show a warning about copying code in " -"general." -msgstr "" -"大多数现代终端在粘贴时都会警告并删除隐藏的字符,所以严格来说这并不是必须的。还有" -"以其他方式生成危险命令的可能,这些都是不可能完全过滤的。根据你的网站的使用情况来" -"做决定,复制代码时显示一个一般警告也是可以的。" +"dangerous commands in other ways that aren't possible to filter. " +"Depending on your site's use case, it may be good to show a warning about" +" copying code in general." +msgstr "大多数现代终端在粘贴时都会警告并删除隐藏的字符,所以严格来说这并不是必须的。还有以其他方式生成危险命令的可能,这些都是不可能完全过滤的。根据你的网站的使用情况来做决定,复制代码时显示一个一般警告也是可以的。" + +#~ msgid "X-XSS-Protection" +#~ msgstr "X-XSS-Protection" + +#~ msgid "" +#~ "The browser will try to prevent " +#~ "reflected XSS attacks by not loading " +#~ "the page if the request contains " +#~ "something that looks like JavaScript and" +#~ " the response contains the same data." +#~ " ::" +#~ msgstr "如果请求中含有一些类似 JavaScript 代码的东西,且响应中包含相同的数据,浏览器将试图通过不加载页面来防止反射式 XSS 攻击。" + +#~ msgid "" +#~ "https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X" +#~ "-XSS-Protection" +#~ msgstr "" +#~ "https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X" +#~ "-XSS-Protection" diff --git a/docs/locales/zh_CN/LC_MESSAGES/server.po b/docs/locales/zh_CN/LC_MESSAGES/server.po index 647e24d50..61d8c6448 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/server.po +++ b/docs/locales/zh_CN/LC_MESSAGES/server.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: zh_CN \n" @@ -56,14 +56,18 @@ msgid "Bash" msgstr "" #: ../../server.rst:36 -msgid "CMD" +msgid "Fish" msgstr "" #: ../../server.rst:44 -msgid "Powershell" +msgid "CMD" msgstr "" #: ../../server.rst:52 +msgid "Powershell" +msgstr "" + +#: ../../server.rst:60 msgid "" "This enables the development environment, including the interactive " "debugger and reloader, and then starts the server on " @@ -72,7 +76,7 @@ msgid "" " using the CLI." msgstr "" -#: ../../server.rst:60 +#: ../../server.rst:68 msgid "" "Prior to Flask 1.0 the ``FLASK_ENV`` environment variable was not " "supported and you needed to enable debug mode by exporting " @@ -80,11 +84,64 @@ msgid "" "should prefer setting the development environment as shown above." msgstr "" -#: ../../server.rst:68 +#: ../../server.rst:78 +msgid "Address already in use" +msgstr "" + +#: ../../server.rst:80 +msgid "" +"If another program is already using port 5000, you'll see an ``OSError`` " +"when the server tries to start. It may have one of the following " +"messages:" +msgstr "" + +#: ../../server.rst:84 +msgid "``OSError: [Errno 98] Address already in use``" +msgstr "" + +#: ../../server.rst:85 +msgid "" +"``OSError: [WinError 10013] An attempt was made to access a socket in a " +"way forbidden by its access permissions``" +msgstr "" + +#: ../../server.rst:88 +msgid "" +"Either identify and stop the other program, or use ``flask run --port " +"5001`` to pick a different port." +msgstr "" + +#: ../../server.rst:91 +msgid "" +"You can use ``netstat`` or ``lsof`` to identify what process id is using " +"a port, then use other operating system tools stop that process. The " +"following example shows that process id 6847 is using port 5000." +msgstr "" + +#: ../../server.rst:97 +msgid "``netstat`` (Linux)" +msgstr "" + +#: ../../server.rst:104 +msgid "``lsof`` (macOS / Linux)" +msgstr "" + +#: ../../server.rst:111 +msgid "``netstat`` (Windows)" +msgstr "" + +#: ../../server.rst:118 +msgid "" +"macOS Monterey and later automatically starts a service that uses port " +"5000. To disable the service, go to System Preferences, Sharing, and " +"disable \"AirPlay Receiver\"." +msgstr "" + +#: ../../server.rst:124 msgid "Lazy or Eager Loading" msgstr "" -#: ../../server.rst:70 +#: ../../server.rst:126 msgid "" "When using the ``flask run`` command with the reloader, the server will " "continue to run even if you introduce syntax errors or other " @@ -93,7 +150,7 @@ msgid "" " feature is called \"lazy loading\"." msgstr "" -#: ../../server.rst:76 +#: ../../server.rst:132 msgid "" "If a syntax error is already present when calling ``flask run``, it will " "fail immediately and show the traceback rather than waiting until the " @@ -101,18 +158,18 @@ msgid "" "while still allowing the server to handle errors on reload." msgstr "" -#: ../../server.rst:81 +#: ../../server.rst:137 msgid "" "To override this behavior and always fail immediately, even on reload, " "pass the ``--eager-loading`` option. To always keep the server running, " "even on the initial call, pass ``--lazy-loading``." msgstr "" -#: ../../server.rst:87 +#: ../../server.rst:143 msgid "In Code" msgstr "" -#: ../../server.rst:89 +#: ../../server.rst:145 msgid "" "As an alternative to the ``flask run`` command, the development server " "can also be started from Python with the :meth:`Flask.run` method. This " @@ -121,14 +178,14 @@ msgid "" " there are errors when reloading." msgstr "" -#: ../../server.rst:95 +#: ../../server.rst:151 msgid "" "``debug=True`` can be passed to enable the debugger and reloader, but the" " ``FLASK_ENV=development`` environment variable is still required to " "fully enable development mode." msgstr "" -#: ../../server.rst:99 +#: ../../server.rst:155 msgid "" "Place the call in a main block, otherwise it will interfere when trying " "to import and run the application with a production server later." diff --git a/docs/locales/zh_CN/LC_MESSAGES/shell.po b/docs/locales/zh_CN/LC_MESSAGES/shell.po index 07cd5a29e..2becf83e6 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/shell.po +++ b/docs/locales/zh_CN/LC_MESSAGES/shell.po @@ -7,16 +7,16 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: 2021-06-12 13:42+0800\n" +"Last-Translator: LTakamori \n" +"Language: zh_CN\n" "Language-Team: zh_CN \n" +"Plural-Forms: nplurals=1; plural=0\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.9.1\n" -"Last-Translator: LTakamori \n" -"Language: zh_CN\n" -"X-Generator: Poedit 3.0\n" #: ../../shell.rst:2 msgid "Working with the Shell" @@ -27,26 +27,23 @@ msgid "" "One of the reasons everybody loves Python is the interactive shell. It " "basically allows you to execute Python commands in real time and " "immediately get results back. Flask itself does not come with an " -"interactive shell, because it does not require any specific setup upfront, " -"just import your application and start playing around." +"interactive shell, because it does not require any specific setup " +"upfront, just import your application and start playing around." msgstr "" -"人们喜爱 Python 的原因之一就是它交互式的 shell。它基本上允许你实时地执行 " -"Python 指令并立即获得反馈结果。 Flask 本身并没有附带一个交互式的 shell,因为" -"它并不需要任何具体的前置条件,你只需要导入你的程序就可以愉快地玩耍了。" +"人们喜爱 Python 的原因之一就是它交互式的 shell。它基本上允许你实时地执行 Python 指令并立即获得反馈结果。 Flask " +"本身并没有附带一个交互式的 shell,因为它并不需要任何具体的前置条件,你只需要导入你的程序就可以愉快地玩耍了。" #: ../../shell.rst:12 msgid "" -"There are however some handy helpers to make playing around in the shell a " -"more pleasant experience. The main issue with interactive console sessions " -"is that you're not triggering a request like a browser does which means " -"that :data:`~flask.g`, :data:`~flask.request` and others are not " -"available. But the code you want to test might depend on them, so what can " -"you do?" +"There are however some handy helpers to make playing around in the shell " +"a more pleasant experience. The main issue with interactive console " +"sessions is that you're not triggering a request like a browser does " +"which means that :data:`~flask.g`, :data:`~flask.request` and others are " +"not available. But the code you want to test might depend on them, so " +"what can you do?" msgstr "" -"不过依然存在一些便利的辅助工具,它们使得你使用 shell 的体验更加愉快。交互式" -"的控制台中的主要问题是你不能像浏览器一样触发一个请求,即无法使用 :data:" -"`~flask.g`,:data:`~flask.request` 等对象。但假如你写的代码依赖它们来进行调" -"试,那么你应该怎么做呢?" +"不过依然存在一些便利的辅助工具,它们使得你使用 shell 的体验更加愉快。交互式的控制台中的主要问题是你不能像浏览器一样触发一个请求,即无法使用" +" :data:`~flask.g`,:data:`~flask.request` 等对象。但假如你写的代码依赖它们来进行调试,那么你应该怎么做呢?" #: ../../shell.rst:19 msgid "" @@ -54,132 +51,123 @@ msgid "" "that these functions are not only there for interactive shell usage, but " "also for unit testing and other situations that require a faked request " "context." -msgstr "" -"这就是一些辅助函数大展拳脚的场景了。不过请牢记,这些函数不仅适用于交互式 " -"shell 的场景下,还能用于单元测试以及其他需要伪造请求的情况。" +msgstr "这就是一些辅助函数大展拳脚的场景了。不过请牢记,这些函数不仅适用于交互式 shell 的场景下,还能用于单元测试以及其他需要伪造请求的情况。" #: ../../shell.rst:24 -msgid "" -"Generally it's recommended that you read the :doc:`reqcontext` chapter of " -"the documentation first." +#, fuzzy +msgid "Generally it's recommended that you read :doc:`reqcontext` first." msgstr "通常情况下建议先阅读 :doc:`reqcontext` 这一章节。" -#: ../../shell.rst:28 +#: ../../shell.rst:27 msgid "Command Line Interface" msgstr "命令行接口" -#: ../../shell.rst:30 +#: ../../shell.rst:29 msgid "" -"Starting with Flask 0.11 the recommended way to work with the shell is the " -"``flask shell`` command which does a lot of this automatically for you. For " -"instance the shell is automatically initialized with a loaded application " -"context." +"Starting with Flask 0.11 the recommended way to work with the shell is " +"the ``flask shell`` command which does a lot of this automatically for " +"you. For instance the shell is automatically initialized with a loaded " +"application context." msgstr "" -"自 Flask 0.11 开始,推荐使用 ``flask shell`` 命令来使用 shell ,它能为你自动" -"完成许多工作。比如自动地为你初始化一个 shell 并加载好应用上下文。" +"自 Flask 0.11 开始,推荐使用 ``flask shell`` 命令来使用 shell " +",它能为你自动完成许多工作。比如自动地为你初始化一个 shell 并加载好应用上下文。" -#: ../../shell.rst:35 +#: ../../shell.rst:34 msgid "For more information see :doc:`/cli`." msgstr "更多信息可以查阅 :doc:`/cli`。" -#: ../../shell.rst:38 +#: ../../shell.rst:37 msgid "Creating a Request Context" msgstr "创建一个请求上下文" -#: ../../shell.rst:40 +#: ../../shell.rst:39 msgid "" "The easiest way to create a proper request context from the shell is by " -"using the :attr:`~flask.Flask.test_request_context` method which creates us " -"a :class:`~flask.ctx.RequestContext`:" +"using the :attr:`~flask.Flask.test_request_context` method which creates " +"us a :class:`~flask.ctx.RequestContext`:" msgstr "" -"在 shell 中创建一个正确的请求上下文最简单的方法就是使用 :attr:`~flask.Flask." -"test_request_context` 方法,它能为我们创建一个 :class:`~flask.ctx." -"RequestContext`:" +"在 shell 中创建一个正确的请求上下文最简单的方法就是使用 :attr:`~flask.Flask.test_request_context`" +" 方法,它能为我们创建一个 :class:`~flask.ctx.RequestContext`:" -#: ../../shell.rst:46 +#: ../../shell.rst:45 msgid "" -"Normally you would use the ``with`` statement to make this request object " -"active, but in the shell it's easier to use the :meth:`~flask.ctx." -"RequestContext.push` and :meth:`~flask.ctx.RequestContext.pop` methods by " -"hand:" +"Normally you would use the ``with`` statement to make this request object" +" active, but in the shell it's easier to use the " +":meth:`~flask.ctx.RequestContext.push` and " +":meth:`~flask.ctx.RequestContext.pop` methods by hand:" msgstr "" -"通常来说你会使用 ``with`` 语句来激活请求对象,不过在 shell 中更方便的做法是" -"手动调用 :meth:`~flask.ctx.RequestContext.push` 和 :meth:`~flask.ctx." -"RequestContext.pop` 方法:" +"通常来说你会使用 ``with`` 语句来激活请求对象,不过在 shell 中更方便的做法是手动调用 " +":meth:`~flask.ctx.RequestContext.push` 和 " +":meth:`~flask.ctx.RequestContext.pop` 方法:" -#: ../../shell.rst:53 +#: ../../shell.rst:52 msgid "" -"From that point onwards you can work with the request object until you call " -"`pop`:" +"From that point onwards you can work with the request object until you " +"call `pop`:" msgstr "从这时开始,直到调用 `pop` 之前,你可以使用请求对象:" -#: ../../shell.rst:59 +#: ../../shell.rst:58 msgid "Firing Before/After Request" msgstr "触发请求前/后的动作" -#: ../../shell.rst:61 +#: ../../shell.rst:60 msgid "" -"By just creating a request context, you still don't have run the code that " -"is normally run before a request. This might result in your database being " -"unavailable if you are connecting to the database in a before-request " -"callback or the current user not being stored on the :data:`~flask.g` " -"object etc." +"By just creating a request context, you still don't have run the code " +"that is normally run before a request. This might result in your " +"database being unavailable if you are connecting to the database in a " +"before-request callback or the current user not being stored on the " +":data:`~flask.g` object etc." msgstr "" -"仅仅创建请求上下文还不够,你还没有执行请求前的一般会执行的动作。假如在请求前" -"的钩子中包含了连接数据库的操作,这会导致你的数据库仍不可用,这么做还有可能导" -"致当前用户没有被存储在 :data:`~flask.g` 中等一系列错误。" +"仅仅创建请求上下文还不够,你还没有执行请求前的一般会执行的动作。假如在请求前的钩子中包含了连接数据库的操作,这会导致你的数据库仍不可用,这么做还有可能导致当前用户没有被存储在" +" :data:`~flask.g` 中等一系列错误。" -#: ../../shell.rst:67 +#: ../../shell.rst:66 msgid "" -"This however can easily be done yourself. Just call :meth:`~flask.Flask." -"preprocess_request`:" -msgstr "" -"我们可以很轻松地解决这个问题。只要调用 :meth:`~flask.Flask." -"preprocess_request` 就可以了:" +"This however can easily be done yourself. Just call " +":meth:`~flask.Flask.preprocess_request`:" +msgstr "我们可以很轻松地解决这个问题。只要调用 :meth:`~flask.Flask.preprocess_request` 就可以了:" -#: ../../shell.rst:74 +#: ../../shell.rst:73 msgid "" "Keep in mind that the :meth:`~flask.Flask.preprocess_request` function " "might return a response object, in that case just ignore it." msgstr "" -"请记住,:meth:`~flask.Flask.preprocess_request` 函数可能会返回一个响应对象," -"但在这种情况下,忽略这个返回值就好了。" +"请记住,:meth:`~flask.Flask.preprocess_request` " +"函数可能会返回一个响应对象,但在这种情况下,忽略这个返回值就好了。" -#: ../../shell.rst:77 +#: ../../shell.rst:76 msgid "" "To shutdown a request, you need to trick a bit before the after request " -"functions (triggered by :meth:`~flask.Flask.process_response`) operate on a " -"response object:" +"functions (triggered by :meth:`~flask.Flask.process_response`) operate on" +" a response object:" msgstr "" -"如果要关闭一个请求,你需要在请求后钩子函数(由 :meth:`~flask.Flask." -"process_response` 触发)作用于响应对象前将它关闭:" +"如果要关闭一个请求,你需要在请求后钩子函数(由 :meth:`~flask.Flask.process_response` " +"触发)作用于响应对象前将它关闭:" -#: ../../shell.rst:85 +#: ../../shell.rst:84 msgid "" "The functions registered as :meth:`~flask.Flask.teardown_request` are " "automatically called when the context is popped. So this is the perfect " -"place to automatically tear down resources that were needed by the request " -"context (such as database connections)." +"place to automatically tear down resources that were needed by the " +"request context (such as database connections)." msgstr "" -"注册为 :meth:`~flask.Flask.teardown_request` 的函数会在请求上下文弹出后自动" -"执行。所以,在这里释放之前由请求上下文申请的资源(比如数据库连接)就相当合适" -"了。" +"注册为 :meth:`~flask.Flask.teardown_request` " +"的函数会在请求上下文弹出后自动执行。所以,在这里释放之前由请求上下文申请的资源(比如数据库连接)就相当合适了。" -#: ../../shell.rst:92 +#: ../../shell.rst:91 msgid "Further Improving the Shell Experience" msgstr "提升 Shell 使用体验" -#: ../../shell.rst:94 +#: ../../shell.rst:93 msgid "" -"If you like the idea of experimenting in a shell, create yourself a module " -"with stuff you want to star import into your interactive session. There " -"you could also define some more helper methods for common things such as " -"initializing the database, dropping tables etc." +"If you like the idea of experimenting in a shell, create yourself a " +"module with stuff you want to star import into your interactive session." +" There you could also define some more helper methods for common things " +"such as initializing the database, dropping tables etc." msgstr "" -"如果你喜欢使用 shell 的感觉,你还可以为你自己创建一个包含你想要全部导入内容" -"的模块。你可以在那里定义一些操纵常见资源的辅助方法,比如初始化数据库,删除表" -"等等。" +"如果你喜欢使用 shell " +"的感觉,你还可以为你自己创建一个包含你想要全部导入内容的模块。你可以在那里定义一些操纵常见资源的辅助方法,比如初始化数据库,删除表等等。" -#: ../../shell.rst:99 +#: ../../shell.rst:98 msgid "Just put them into a module (like `shelltools`) and import from there:" msgstr "你只需将它们放入一个模块(比如 `shelltools`)并将其导入即可:" diff --git a/docs/locales/zh_CN/LC_MESSAGES/templating.po b/docs/locales/zh_CN/LC_MESSAGES/templating.po index c93ab258a..f187877d0 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/templating.po +++ b/docs/locales/zh_CN/LC_MESSAGES/templating.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: zh_CN \n" @@ -81,7 +81,7 @@ msgid "" msgstr "" #: ../../templating.rst:40 -msgid "The current configuration object (:data:`flask.config`)" +msgid "The current configuration object (:data:`flask.Flask.config`)" msgstr "" #: ../../templating.rst:44 @@ -271,3 +271,6 @@ msgid "" ":`registering-filters`), but this demonstrates how to pass functions in a" " context processor." msgstr "" + +#~ msgid "The current configuration object (:data:`flask.config`)" +#~ msgstr "" diff --git a/docs/locales/zh_CN/LC_MESSAGES/testing.po b/docs/locales/zh_CN/LC_MESSAGES/testing.po index c5a2c0f9e..1e0914b18 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/testing.po +++ b/docs/locales/zh_CN/LC_MESSAGES/testing.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: zh_CN \n" @@ -22,361 +22,679 @@ msgid "Testing Flask Applications" msgstr "" #: ../../testing.rst:4 -msgid "**Something that is untested is broken.**" -msgstr "" - -#: ../../testing.rst:6 msgid "" -"The origin of this quote is unknown and while it is not entirely correct," -" it is also not far from the truth. Untested applications make it hard " -"to improve existing code and developers of untested applications tend to " -"become pretty paranoid. If an application has automated tests, you can " -"safely make changes and instantly know if anything breaks." +"Flask provides utilities for testing an application. This documentation " +"goes over techniques for working with different parts of the application " +"in tests." msgstr "" -#: ../../testing.rst:12 -msgid "" -"Flask provides a way to test your application by exposing the Werkzeug " -"test :class:`~werkzeug.test.Client` and handling the context locals for " -"you. You can then use that with your favourite testing solution." +#: ../../testing.rst:8 +msgid "We will use the `pytest`_ framework to set up and run our tests." msgstr "" #: ../../testing.rst:16 +#, python-format msgid "" -"In this documentation we will use the `pytest`_ package as the base " -"framework for our tests. You can install it with ``pip``, like so::" +"The :doc:`tutorial ` goes over how to write tests for " +"100% coverage of the sample Flaskr blog application. See :doc:`the " +"tutorial on tests ` for a detailed explanation of " +"specific tests for an application." msgstr "" -#: ../../testing.rst:24 -msgid "The Application" +#: ../../testing.rst:23 +msgid "Identifying Tests" msgstr "" -#: ../../testing.rst:26 +#: ../../testing.rst:25 msgid "" -"First, we need an application to test; we will use the application from " -"the :doc:`tutorial/index`. If you don't have that application yet, get " -"the source code from :gh:`the examples `." +"Tests are typically located in the ``tests`` folder. Tests are functions " +"that start with ``test_``, in Python modules that start with ``test_``. " +"Tests can also be further grouped in classes that start with ``Test``." msgstr "" -#: ../../testing.rst:30 +#: ../../testing.rst:29 msgid "" -"So that we can import the module ``flaskr`` correctly, we need to run " -"``pip install -e .`` in the folder ``tutorial``." -msgstr "" - -#: ../../testing.rst:34 -msgid "The Testing Skeleton" +"It can be difficult to know what to test. Generally, try to test the code" +" that you write, not the code of libraries that you use, since they are " +"already tested. Try to extract complex behaviors as separate functions to" +" test individually." msgstr "" #: ../../testing.rst:36 -msgid "" -"We begin by adding a tests directory under the application root. Then " -"create a Python file to store our tests (:file:`test_flaskr.py`). When we" -" format the filename like ``test_*.py``, it will be auto-discoverable by " -"pytest." -msgstr "" - -#: ../../testing.rst:41 -msgid "" -"Next, we create a `pytest fixture`_ called :func:`client` that configures" -" the application for testing and initializes a new database::" +msgid "Fixtures" msgstr "" -#: ../../testing.rst:66 +#: ../../testing.rst:38 msgid "" -"This client fixture will be called by each individual test. It gives us " -"a simple interface to the application, where we can trigger test requests" -" to the application. The client will also keep track of cookies for us." +"Pytest *fixtures* allow writing pieces of code that are reusable across " +"tests. A simple fixture returns a value, but a fixture can also do setup," +" yield a value, then do teardown. Fixtures for the application, test " +"client, and CLI runner are shown below, they can be placed in " +"``tests/conftest.py``." msgstr "" -#: ../../testing.rst:70 +#: ../../testing.rst:44 msgid "" -"During setup, the ``TESTING`` config flag is activated. What this does " -"is disable error catching during request handling, so that you get better" -" error reports when performing test requests against the application." +"If you're using an :doc:`application factory `, " +"define an ``app`` fixture to create and configure an app instance. You " +"can add code before and after the ``yield`` to set up and tear down other" +" resources, such as creating and clearing a database." msgstr "" -#: ../../testing.rst:75 +#: ../../testing.rst:50 msgid "" -"Because SQLite3 is filesystem-based, we can easily use the " -":mod:`tempfile` module to create a temporary database and initialize it. " -"The :func:`~tempfile.mkstemp` function does two things for us: it returns" -" a low-level file handle and a random file name, the latter we use as " -"database name. We just have to keep the `db_fd` around so that we can " -"use the :func:`os.close` function to close the file." +"If you're not using a factory, you already have an app object you can " +"import and configure directly. You can still use an ``app`` fixture to " +"set up and tear down resources." msgstr "" -#: ../../testing.rst:82 -msgid "" -"To delete the database after the test, the fixture closes the file and " -"removes it from the filesystem." -msgstr "" - -#: ../../testing.rst:85 -msgid "If we now run the test suite, we should see the following output::" +#: ../../testing.rst:84 +msgid "Sending Requests with the Test Client" msgstr "" -#: ../../testing.rst:95 +#: ../../testing.rst:86 msgid "" -"Even though it did not run any actual tests, we already know that our " -"``flaskr`` application is syntactically valid, otherwise the import would" -" have died with an exception." -msgstr "" - -#: ../../testing.rst:103 -msgid "The First Test" +"The test client makes requests to the application without running a live " +"server. Flask's client extends :doc:`Werkzeug's client `, " +"see those docs for additional information." msgstr "" -#: ../../testing.rst:105 +#: ../../testing.rst:91 msgid "" -"Now it's time to start testing the functionality of the application. " -"Let's check that the application shows \"No entries here so far\" if we " -"access the root of the application (``/``). To do this, we add a new " -"test function to :file:`test_flaskr.py`, like this::" +"The ``client`` has methods that match the common HTTP request methods, " +"such as ``client.get()`` and ``client.post()``. They take many arguments " +"for building the request; you can find the full documentation in " +":class:`~werkzeug.test.EnvironBuilder`. Typically you'll use ``path``, " +"``query_string``, ``headers``, and ``data`` or ``json``." msgstr "" -#: ../../testing.rst:116 +#: ../../testing.rst:97 msgid "" -"Notice that our test functions begin with the word `test`; this allows " -"`pytest`_ to automatically identify the function as a test to run." +"To make a request, call the method the request should use with the path " +"to the route to test. A :class:`~werkzeug.test.TestResponse` is returned " +"to examine the response data. It has all the usual properties of a " +"response object. You'll usually look at ``response.data``, which is the " +"bytes returned by the view. If you want to use text, Werkzeug 2.1 " +"provides ``response.text``, or use ``response.get_data(as_text=True)``." msgstr "" -#: ../../testing.rst:119 +#: ../../testing.rst:111 msgid "" -"By using ``client.get`` we can send an HTTP ``GET`` request to the " -"application with the given path. The return value will be a " -":class:`~flask.Flask.response_class` object. We can now use the " -":attr:`~werkzeug.wrappers.Response.data` attribute to inspect the return " -"value (as string) from the application. In this case, we ensure that " -"``'No entries here so far'`` is part of the output." +"Pass a dict ``query_string={\"key\": \"value\", ...}`` to set arguments " +"in the query string (after the ``?`` in the URL). You can also pass a " +"string if you want to set a specific value directly." msgstr "" -#: ../../testing.rst:127 -msgid "Run it again and you should see one passing test::" +#: ../../testing.rst:115 +msgid "Pass a dict to ``headers={}`` to set request headers." msgstr "" -#: ../../testing.rst:140 -msgid "Logging In and Out" -msgstr "" - -#: ../../testing.rst:142 +#: ../../testing.rst:117 msgid "" -"The majority of the functionality of our application is only available " -"for the administrative user, so we need a way to log our test client in " -"and out of the application. To do this, we fire some requests to the " -"login and logout pages with the required form data (username and " -"password). And because the login and logout pages redirect, we tell the " -"client to `follow_redirects`." +"To send a request body in a POST or PUT request, pass a value to " +"``data``. If raw bytes are passed, that exact body is used. Usually, " +"you'll pass a dict to set form data." msgstr "" -#: ../../testing.rst:148 -msgid "Add the following two functions to your :file:`test_flaskr.py` file::" +#: ../../testing.rst:123 +msgid "Form Data" msgstr "" -#: ../../testing.rst:160 +#: ../../testing.rst:125 msgid "" -"Now we can easily test that logging in and out works and that it fails " -"with invalid credentials. Add this new test function::" +"To send form data, pass a dict to ``data``. The ``Content-Type`` header " +"will be set to ``multipart/form-data`` or ``application/x-www-form-" +"urlencoded`` automatically." msgstr "" -#: ../../testing.rst:182 -msgid "Test Adding Messages" -msgstr "" - -#: ../../testing.rst:184 +#: ../../testing.rst:129 msgid "" -"We should also test that adding messages works. Add a new test function " -"like this::" +"If a value is a file object opened for reading bytes (``\"rb\"`` mode), " +"it will be treated as an uploaded file. To change the detected filename " +"and content type, pass a ``(file, filename, content_type)`` tuple. File " +"objects will be closed after making the request, so they do not need to " +"use the usual ``with open() as f:`` pattern." msgstr "" -#: ../../testing.rst:199 +#: ../../testing.rst:135 msgid "" -"Here we check that HTML is allowed in the text but not in the title, " -"which is the intended behavior." -msgstr "" - -#: ../../testing.rst:202 -msgid "Running that should now give us three passing tests::" +"It can be useful to store files in a ``tests/resources`` folder, then use" +" ``pathlib.Path`` to get files relative to the current test file." msgstr "" -#: ../../testing.rst:218 -msgid "Other Testing Tricks" +#: ../../testing.rst:155 +msgid "JSON Data" msgstr "" -#: ../../testing.rst:220 -msgid "" -"Besides using the test client as shown above, there is also the " -":meth:`~flask.Flask.test_request_context` method that can be used in " -"combination with the ``with`` statement to activate a request context " -"temporarily. With this you can access the :class:`~flask.request`, " -":class:`~flask.g` and :class:`~flask.session` objects like in view " -"functions. Here is a full example that demonstrates this approach::" -msgstr "" - -#: ../../testing.rst:235 -msgid "All the other objects that are context bound can be used in the same way." -msgstr "" - -#: ../../testing.rst:238 -msgid "" -"If you want to test your application with different configurations and " -"there does not seem to be a good way to do that, consider switching to " -"application factories (see :doc:`patterns/appfactories`)." -msgstr "" - -#: ../../testing.rst:242 -msgid "" -"Note however that if you are using a test request context, the " -":meth:`~flask.Flask.before_request` and " -":meth:`~flask.Flask.after_request` functions are not called " -"automatically. However :meth:`~flask.Flask.teardown_request` functions " -"are indeed executed when the test request context leaves the ``with`` " -"block. If you do want the :meth:`~flask.Flask.before_request` functions " -"to be called as well, you need to call " -":meth:`~flask.Flask.preprocess_request` yourself::" -msgstr "" - -#: ../../testing.rst:256 +#: ../../testing.rst:157 msgid "" -"This can be necessary to open database connections or something similar " -"depending on how your application was designed." +"To send JSON data, pass an object to ``json``. The ``Content-Type`` " +"header will be set to ``application/json`` automatically." msgstr "" -#: ../../testing.rst:259 -msgid "" -"If you want to call the :meth:`~flask.Flask.after_request` functions you " -"need to call into :meth:`~flask.Flask.process_response` which however " -"requires that you pass it a response object::" -msgstr "" - -#: ../../testing.rst:270 -msgid "" -"This in general is less useful because at that point you can directly " -"start using the test client." -msgstr "" - -#: ../../testing.rst:276 -msgid "Faking Resources and Context" -msgstr "" - -#: ../../testing.rst:280 -msgid "" -"A very common pattern is to store user authorization information and " -"database connections on the application context or the :attr:`flask.g` " -"object. The general pattern for this is to put the object on there on " -"first usage and then to remove it on a teardown. Imagine for instance " -"this code to get the current user::" -msgstr "" - -#: ../../testing.rst:293 -msgid "" -"For a test it would be nice to override this user from the outside " -"without having to change some code. This can be accomplished with " -"hooking the :data:`flask.appcontext_pushed` signal::" -msgstr "" - -#: ../../testing.rst:307 -msgid "And then to use it::" -msgstr "" - -#: ../../testing.rst:323 -msgid "Keeping the Context Around" -msgstr "" - -#: ../../testing.rst:327 -msgid "" -"Sometimes it is helpful to trigger a regular request but still keep the " -"context around for a little longer so that additional introspection can " -"happen. With Flask 0.4 this is possible by using the " -":meth:`~flask.Flask.test_client` with a ``with`` block::" -msgstr "" - -#: ../../testing.rst:338 +#: ../../testing.rst:160 msgid "" -"If you were to use just the :meth:`~flask.Flask.test_client` without the " -"``with`` block, the ``assert`` would fail with an error because `request`" -" is no longer available (because you are trying to use it outside of the " -"actual request)." -msgstr "" - -#: ../../testing.rst:345 -msgid "Accessing and Modifying Sessions" +"Similarly, if the response contains JSON data, the ``response.json`` " +"attribute will contain the deserialized object." msgstr "" -#: ../../testing.rst:349 -msgid "" -"Sometimes it can be very helpful to access or modify the sessions from " -"the test client. Generally there are two ways for this. If you just " -"want to ensure that a session has certain keys set to certain values you " -"can just keep the context around and access :data:`flask.session`::" +#: ../../testing.rst:182 +msgid "Following Redirects" msgstr "" -#: ../../testing.rst:358 +#: ../../testing.rst:184 msgid "" -"This however does not make it possible to also modify the session or to " -"access the session before a request was fired. Starting with Flask 0.8 " -"we provide a so called “session transaction” which simulates the " -"appropriate calls to open a session in the context of the test client and" -" to modify it. At the end of the transaction the session is stored and " -"ready to be used by the test client. This works independently of the " -"session backend used::" +"By default, the client does not make additional requests if the response " +"is a redirect. By passing ``follow_redirects=True`` to a request method, " +"the client will continue to make requests until a non-redirect response " +"is returned." msgstr "" -#: ../../testing.rst:372 +#: ../../testing.rst:189 msgid "" -"Note that in this case you have to use the ``sess`` object instead of the" -" :data:`flask.session` proxy. The object however itself will provide the" -" same interface." +":attr:`TestResponse.history ` is a " +"tuple of the responses that led up to the final response. Each response " +"has a :attr:`~werkzeug.test.TestResponse.request` attribute which records" +" the request that produced that response." msgstr "" -#: ../../testing.rst:378 -msgid "Testing JSON APIs" +#: ../../testing.rst:205 +msgid "Accessing and Modifying the Session" msgstr "" -#: ../../testing.rst:382 +#: ../../testing.rst:207 msgid "" -"Flask has great support for JSON, and is a popular choice for building " -"JSON APIs. Making requests with JSON data and examining JSON data in " -"responses is very convenient::" +"To access Flask's context variables, mainly :data:`~flask.session`, use " +"the client in a ``with`` statement. The app and request context will " +"remain active *after* making a request, until the ``with`` block ends." msgstr "" -#: ../../testing.rst:402 +#: ../../testing.rst:224 msgid "" -"Passing the ``json`` argument in the test client methods sets the request" -" data to the JSON-serialized object and sets the content type to " -"``application/json``. You can get the JSON data from the request or " -"response with ``get_json``." +"If you want to access or set a value in the session *before* making a " +"request, use the client's " +":meth:`~flask.testing.FlaskClient.session_transaction` method in a " +"``with`` statement. It returns a session object, and will save the " +"session once the block ends." msgstr "" -#: ../../testing.rst:411 -msgid "Testing CLI Commands" +#: ../../testing.rst:248 +msgid "Running Commands with the CLI Runner" msgstr "" -#: ../../testing.rst:413 +#: ../../testing.rst:250 msgid "" -"Click comes with `utilities for testing`_ your CLI commands. A " -":class:`~click.testing.CliRunner` runs commands in isolation and captures" -" the output in a :class:`~click.testing.Result` object." +"Flask provides :meth:`~flask.Flask.test_cli_runner` to create a " +":class:`~flask.testing.FlaskCliRunner`, which runs CLI commands in " +"isolation and captures the output in a :class:`~click.testing.Result` " +"object. Flask's runner extends :doc:`Click's runner `, see" +" those docs for additional information." msgstr "" -#: ../../testing.rst:417 +#: ../../testing.rst:256 msgid "" -"Flask provides :meth:`~flask.Flask.test_cli_runner` to create a " -":class:`~flask.testing.FlaskCliRunner` that passes the Flask app to the " -"CLI automatically. Use its :meth:`~flask.testing.FlaskCliRunner.invoke` " -"method to call commands in the same way they would be called from the " -"command line. ::" +"Use the runner's :meth:`~flask.testing.FlaskCliRunner.invoke` method to " +"call commands in the same way they would be called with the ``flask`` " +"command from the command line." msgstr "" -#: ../../testing.rst:441 -msgid "" -"In the example above, invoking the command by name is useful because it " -"verifies that the command was correctly registered with the app." +#: ../../testing.rst:278 +msgid "Tests that depend on an Active Context" msgstr "" -#: ../../testing.rst:444 +#: ../../testing.rst:280 msgid "" -"If you want to test how your command parses parameters, without running " -"the command, use its :meth:`~click.BaseCommand.make_context` method. This" -" is useful for testing complex validation rules and custom types. ::" -msgstr "" +"You may have functions that are called from views or commands, that " +"expect an active :doc:`application context ` or " +":doc:`request context ` because they access ``request``, " +"``session``, or ``current_app``. Rather than testing them by making a " +"request or invoking the command, you can create and activate a context " +"directly." +msgstr "" + +#: ../../testing.rst:287 +msgid "" +"Use ``with app.app_context()`` to push an application context. For " +"example, database extensions usually require an active app context to " +"make queries." +msgstr "" + +#: ../../testing.rst:297 +msgid "" +"Use ``with app.test_request_context()`` to push a request context. It " +"takes the same arguments as the test client's request methods." +msgstr "" + +#: ../../testing.rst:311 +msgid "" +"Creating a test request context doesn't run any of the Flask dispatching " +"code, so ``before_request`` functions are not called. If you need to call" +" these, usually it's better to make a full request instead. However, it's" +" possible to call them manually." +msgstr "" + +#~ msgid "**Something that is untested is broken.**" +#~ msgstr "" + +#~ msgid "" +#~ "The origin of this quote is " +#~ "unknown and while it is not " +#~ "entirely correct, it is also not " +#~ "far from the truth. Untested " +#~ "applications make it hard to improve " +#~ "existing code and developers of untested" +#~ " applications tend to become pretty " +#~ "paranoid. If an application has " +#~ "automated tests, you can safely make " +#~ "changes and instantly know if anything" +#~ " breaks." +#~ msgstr "" + +#~ msgid "" +#~ "Flask provides a way to test your" +#~ " application by exposing the Werkzeug " +#~ "test :class:`~werkzeug.test.Client` and handling " +#~ "the context locals for you. You " +#~ "can then use that with your " +#~ "favourite testing solution." +#~ msgstr "" + +#~ msgid "" +#~ "In this documentation we will use " +#~ "the `pytest`_ package as the base " +#~ "framework for our tests. You can " +#~ "install it with ``pip``, like so::" +#~ msgstr "" + +#~ msgid "The Application" +#~ msgstr "" + +#~ msgid "" +#~ "First, we need an application to " +#~ "test; we will use the application " +#~ "from the :doc:`tutorial/index`. If you " +#~ "don't have that application yet, get " +#~ "the source code from :gh:`the examples" +#~ " `." +#~ msgstr "" + +#~ msgid "" +#~ "So that we can import the module" +#~ " ``flaskr`` correctly, we need to run" +#~ " ``pip install -e .`` in the " +#~ "folder ``tutorial``." +#~ msgstr "" + +#~ msgid "The Testing Skeleton" +#~ msgstr "" + +#~ msgid "" +#~ "We begin by adding a tests " +#~ "directory under the application root. " +#~ "Then create a Python file to store" +#~ " our tests (:file:`test_flaskr.py`). When " +#~ "we format the filename like " +#~ "``test_*.py``, it will be auto-" +#~ "discoverable by pytest." +#~ msgstr "" + +#~ msgid "" +#~ "Next, we create a `pytest fixture`_ " +#~ "called :func:`client` that configures the " +#~ "application for testing and initializes " +#~ "a new database::" +#~ msgstr "" + +#~ msgid "" +#~ "This client fixture will be called " +#~ "by each individual test. It gives " +#~ "us a simple interface to the " +#~ "application, where we can trigger test" +#~ " requests to the application. The " +#~ "client will also keep track of " +#~ "cookies for us." +#~ msgstr "" + +#~ msgid "" +#~ "During setup, the ``TESTING`` config " +#~ "flag is activated. What this does " +#~ "is disable error catching during request" +#~ " handling, so that you get better " +#~ "error reports when performing test " +#~ "requests against the application." +#~ msgstr "" + +#~ msgid "" +#~ "Because SQLite3 is filesystem-based, we" +#~ " can easily use the :mod:`tempfile` " +#~ "module to create a temporary database" +#~ " and initialize it. The " +#~ ":func:`~tempfile.mkstemp` function does two " +#~ "things for us: it returns a " +#~ "low-level file handle and a random" +#~ " file name, the latter we use " +#~ "as database name. We just have to" +#~ " keep the `db_fd` around so that " +#~ "we can use the :func:`os.close` function" +#~ " to close the file." +#~ msgstr "" + +#~ msgid "" +#~ "To delete the database after the " +#~ "test, the fixture closes the file " +#~ "and removes it from the filesystem." +#~ msgstr "" + +#~ msgid "If we now run the test suite, we should see the following output::" +#~ msgstr "" + +#~ msgid "" +#~ "Even though it did not run any " +#~ "actual tests, we already know that " +#~ "our ``flaskr`` application is syntactically" +#~ " valid, otherwise the import would " +#~ "have died with an exception." +#~ msgstr "" + +#~ msgid "The First Test" +#~ msgstr "" + +#~ msgid "" +#~ "Now it's time to start testing the" +#~ " functionality of the application. Let's" +#~ " check that the application shows " +#~ "\"No entries here so far\" if we" +#~ " access the root of the application" +#~ " (``/``). To do this, we add a" +#~ " new test function to " +#~ ":file:`test_flaskr.py`, like this::" +#~ msgstr "" + +#~ msgid "" +#~ "Notice that our test functions begin " +#~ "with the word `test`; this allows " +#~ "`pytest`_ to automatically identify the " +#~ "function as a test to run." +#~ msgstr "" + +#~ msgid "" +#~ "By using ``client.get`` we can send " +#~ "an HTTP ``GET`` request to the " +#~ "application with the given path. The" +#~ " return value will be a " +#~ ":class:`~flask.Flask.response_class` object. We can" +#~ " now use the " +#~ ":attr:`~werkzeug.wrappers.Response.data` attribute to " +#~ "inspect the return value (as string) " +#~ "from the application. In this case, " +#~ "we ensure that ``'No entries here " +#~ "so far'`` is part of the output." +#~ msgstr "" + +#~ msgid "Run it again and you should see one passing test::" +#~ msgstr "" + +#~ msgid "Logging In and Out" +#~ msgstr "" + +#~ msgid "" +#~ "The majority of the functionality of " +#~ "our application is only available for" +#~ " the administrative user, so we need" +#~ " a way to log our test client" +#~ " in and out of the application. " +#~ "To do this, we fire some requests" +#~ " to the login and logout pages " +#~ "with the required form data (username" +#~ " and password). And because the " +#~ "login and logout pages redirect, we " +#~ "tell the client to `follow_redirects`." +#~ msgstr "" + +#~ msgid "Add the following two functions to your :file:`test_flaskr.py` file::" +#~ msgstr "" + +#~ msgid "" +#~ "Now we can easily test that " +#~ "logging in and out works and that" +#~ " it fails with invalid credentials. " +#~ "Add this new test function::" +#~ msgstr "" + +#~ msgid "Test Adding Messages" +#~ msgstr "" + +#~ msgid "" +#~ "We should also test that adding " +#~ "messages works. Add a new test " +#~ "function like this::" +#~ msgstr "" + +#~ msgid "" +#~ "Here we check that HTML is allowed" +#~ " in the text but not in the " +#~ "title, which is the intended behavior." +#~ msgstr "" + +#~ msgid "Running that should now give us three passing tests::" +#~ msgstr "" + +#~ msgid "Other Testing Tricks" +#~ msgstr "" + +#~ msgid "" +#~ "Besides using the test client as " +#~ "shown above, there is also the " +#~ ":meth:`~flask.Flask.test_request_context` method that " +#~ "can be used in combination with " +#~ "the ``with`` statement to activate a " +#~ "request context temporarily. With this " +#~ "you can access the :class:`~flask.request`," +#~ " :class:`~flask.g` and :class:`~flask.session` " +#~ "objects like in view functions. Here" +#~ " is a full example that demonstrates" +#~ " this approach::" +#~ msgstr "" + +#~ msgid "" +#~ "All the other objects that are " +#~ "context bound can be used in the" +#~ " same way." +#~ msgstr "" + +#~ msgid "" +#~ "If you want to test your " +#~ "application with different configurations and" +#~ " there does not seem to be a" +#~ " good way to do that, consider " +#~ "switching to application factories (see " +#~ ":doc:`patterns/appfactories`)." +#~ msgstr "" + +#~ msgid "" +#~ "Note however that if you are using" +#~ " a test request context, the " +#~ ":meth:`~flask.Flask.before_request` and " +#~ ":meth:`~flask.Flask.after_request` functions are not" +#~ " called automatically. However " +#~ ":meth:`~flask.Flask.teardown_request` functions are " +#~ "indeed executed when the test request" +#~ " context leaves the ``with`` block. " +#~ "If you do want the " +#~ ":meth:`~flask.Flask.before_request` functions to be" +#~ " called as well, you need to " +#~ "call :meth:`~flask.Flask.preprocess_request` yourself::" +#~ msgstr "" + +#~ msgid "" +#~ "This can be necessary to open " +#~ "database connections or something similar " +#~ "depending on how your application was" +#~ " designed." +#~ msgstr "" + +#~ msgid "" +#~ "If you want to call the " +#~ ":meth:`~flask.Flask.after_request` functions you " +#~ "need to call into " +#~ ":meth:`~flask.Flask.process_response` which however " +#~ "requires that you pass it a " +#~ "response object::" +#~ msgstr "" + +#~ msgid "" +#~ "This in general is less useful " +#~ "because at that point you can " +#~ "directly start using the test client." +#~ msgstr "" + +#~ msgid "Faking Resources and Context" +#~ msgstr "" + +#~ msgid "" +#~ "A very common pattern is to store" +#~ " user authorization information and " +#~ "database connections on the application " +#~ "context or the :attr:`flask.g` object. " +#~ "The general pattern for this is to" +#~ " put the object on there on " +#~ "first usage and then to remove it" +#~ " on a teardown. Imagine for instance" +#~ " this code to get the current " +#~ "user::" +#~ msgstr "" + +#~ msgid "" +#~ "For a test it would be nice " +#~ "to override this user from the " +#~ "outside without having to change some" +#~ " code. This can be accomplished with" +#~ " hooking the :data:`flask.appcontext_pushed` " +#~ "signal::" +#~ msgstr "" + +#~ msgid "And then to use it::" +#~ msgstr "" + +#~ msgid "Keeping the Context Around" +#~ msgstr "" + +#~ msgid "" +#~ "Sometimes it is helpful to trigger " +#~ "a regular request but still keep " +#~ "the context around for a little " +#~ "longer so that additional introspection " +#~ "can happen. With Flask 0.4 this " +#~ "is possible by using the " +#~ ":meth:`~flask.Flask.test_client` with a ``with`` " +#~ "block::" +#~ msgstr "" + +#~ msgid "" +#~ "If you were to use just the " +#~ ":meth:`~flask.Flask.test_client` without the " +#~ "``with`` block, the ``assert`` would " +#~ "fail with an error because `request` " +#~ "is no longer available (because you " +#~ "are trying to use it outside of" +#~ " the actual request)." +#~ msgstr "" + +#~ msgid "Accessing and Modifying Sessions" +#~ msgstr "" + +#~ msgid "" +#~ "Sometimes it can be very helpful " +#~ "to access or modify the sessions " +#~ "from the test client. Generally there" +#~ " are two ways for this. If you" +#~ " just want to ensure that a " +#~ "session has certain keys set to " +#~ "certain values you can just keep " +#~ "the context around and access " +#~ ":data:`flask.session`::" +#~ msgstr "" + +#~ msgid "" +#~ "This however does not make it " +#~ "possible to also modify the session " +#~ "or to access the session before a" +#~ " request was fired. Starting with " +#~ "Flask 0.8 we provide a so called" +#~ " “session transaction” which simulates the" +#~ " appropriate calls to open a session" +#~ " in the context of the test " +#~ "client and to modify it. At the" +#~ " end of the transaction the session" +#~ " is stored and ready to be used" +#~ " by the test client. This works " +#~ "independently of the session backend " +#~ "used::" +#~ msgstr "" + +#~ msgid "" +#~ "Note that in this case you have" +#~ " to use the ``sess`` object instead" +#~ " of the :data:`flask.session` proxy. The" +#~ " object however itself will provide " +#~ "the same interface." +#~ msgstr "" + +#~ msgid "Testing JSON APIs" +#~ msgstr "" + +#~ msgid "" +#~ "Flask has great support for JSON, " +#~ "and is a popular choice for " +#~ "building JSON APIs. Making requests with" +#~ " JSON data and examining JSON data" +#~ " in responses is very convenient::" +#~ msgstr "" + +#~ msgid "" +#~ "Passing the ``json`` argument in the " +#~ "test client methods sets the request " +#~ "data to the JSON-serialized object " +#~ "and sets the content type to " +#~ "``application/json``. You can get the " +#~ "JSON data from the request or " +#~ "response with ``get_json``." +#~ msgstr "" + +#~ msgid "Testing CLI Commands" +#~ msgstr "" + +#~ msgid "" +#~ "Click comes with `utilities for " +#~ "testing`_ your CLI commands. A " +#~ ":class:`~click.testing.CliRunner` runs commands in" +#~ " isolation and captures the output in" +#~ " a :class:`~click.testing.Result` object." +#~ msgstr "" + +#~ msgid "" +#~ "Flask provides :meth:`~flask.Flask.test_cli_runner` " +#~ "to create a :class:`~flask.testing.FlaskCliRunner`" +#~ " that passes the Flask app to " +#~ "the CLI automatically. Use its " +#~ ":meth:`~flask.testing.FlaskCliRunner.invoke` method to " +#~ "call commands in the same way they" +#~ " would be called from the command " +#~ "line. ::" +#~ msgstr "" + +#~ msgid "" +#~ "In the example above, invoking the " +#~ "command by name is useful because " +#~ "it verifies that the command was " +#~ "correctly registered with the app." +#~ msgstr "" + +#~ msgid "" +#~ "If you want to test how your " +#~ "command parses parameters, without running " +#~ "the command, use its " +#~ ":meth:`~click.BaseCommand.make_context` method. This " +#~ "is useful for testing complex validation" +#~ " rules and custom types. ::" +#~ msgstr "" diff --git a/docs/locales/zh_CN/LC_MESSAGES/tutorial/deploy.po b/docs/locales/zh_CN/LC_MESSAGES/tutorial/deploy.po index 1389dc8fb..7e81bd132 100755 --- a/docs/locales/zh_CN/LC_MESSAGES/tutorial/deploy.po +++ b/docs/locales/zh_CN/LC_MESSAGES/tutorial/deploy.po @@ -1,193 +1,187 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2010 Pallets -# This file is distributed under the same license as the Flask package. -# Grey Li , 2021. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: Flask 2.1.x\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: Grey Li \n" -"Language-Team: zh_CN \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.9.1\n" - -#: ../../tutorial/deploy.rst:2 -msgid "Deploy to Production" -msgstr "部署到生产环境" - -#: ../../tutorial/deploy.rst:4 -msgid "" -"This part of the tutorial assumes you have a server that you want to " -"deploy your application to. It gives an overview of how to create the " -"distribution file and install it, but won't go into specifics about what " -"server or software to use. You can set up a new environment on your " -"development computer to try out the instructions below, but probably " -"shouldn't use it for hosting a real public application. See " -":doc:`/deploying/index` for a list of many different ways to host your " -"application." -msgstr "" -"这部分教程假设你有一台服务器,你想把程序部署上去。这一章会概括如何创建分发文件并安装它," -"但是不会涉及具体使用哪一种服务器或软件。你可以在你的开发电脑上设置一个新环境并尝试下面的" -"操作说明,但可能不应该用它来托管一个真正的公开应用。参阅 :doc:`/deploying/index` " -"了解托管你的应用的多种不同方式。" - -#: ../../tutorial/deploy.rst:15 -msgid "Build and Install" -msgstr "构建和安装" - -#: ../../tutorial/deploy.rst:17 -msgid "" -"When you want to deploy your application elsewhere, you build a " -"distribution file. The current standard for Python distribution is the " -"*wheel* format, with the ``.whl`` extension. Make sure the wheel library " -"is installed first:" -msgstr "" -"当你想要在其他地方部署你的应用时,你要创建一个分发文件。目前 Python 分发的标准是 *wheel* " -"格式,它使用 ``.whl`` 后缀。首先确保 wheel 库已经被安装:" - -#: ../../tutorial/deploy.rst:26 -msgid "" -"Running ``setup.py`` with Python gives you a command line tool to issue " -"build-related commands. The ``bdist_wheel`` command will build a wheel " -"distribution file." -msgstr "" -"使用 Python 运行 ``setup.py`` 给你提供了一个包含构建相关命令的命令行工具。其中 " -"``bdist_wheel`` 命令将会构建一个 wheel 分发文件。" - -#: ../../tutorial/deploy.rst:34 -msgid "" -"You can find the file in ``dist/flaskr-1.0.0-py3-none-any.whl``. The file" -" name is in the format of {project name}-{version}-{python tag} -{abi " -"tag}-{platform tag}." -msgstr "" -"你可以在 ``dist/flaskr-1.0.0-py3-none-any.whl`` 找到这个文件。文件名的格式为:" -"{项目名称}-{版本}-{python 标签} -{abi 标签}-{平台标签}。" - -#: ../../tutorial/deploy.rst:38 -msgid "" -"Copy this file to another machine, :ref:`set up a new virtualenv " -"`, then install the file with ``pip``." -msgstr "" -"把这个文件复制到另一台机器,:ref:`设置一个新的虚拟环境 `,然后使用 " -"``pip`` 安装它。" - -#: ../../tutorial/deploy.rst:46 -msgid "Pip will install your project along with its dependencies." -msgstr "pip 会安装你的项目及其依赖。" - -#: ../../tutorial/deploy.rst:48 -msgid "" -"Since this is a different machine, you need to run ``init-db`` again to " -"create the database in the instance folder." -msgstr "由于这是一台不同的机器,你需要再次运行 ``init-db`` 命令在实例文件夹内创建数据库。" - -#: ../../tutorial/deploy.rst:53 -msgid "Bash" -msgstr "Bash" - -#: ../../tutorial/deploy.rst:60 -msgid "CMD" -msgstr "CMD" - -#: ../../tutorial/deploy.rst:67 -msgid "Powershell" -msgstr "Powershell" - -#: ../../tutorial/deploy.rst:74 -msgid "" -"When Flask detects that it's installed (not in editable mode), it uses a " -"different directory for the instance folder. You can find it at " -"``venv/var/flaskr-instance`` instead." -msgstr "" -"当 Flask 检测到它已经被安装(不在可编辑模式下),它会使用一个不同的目录作为实例文件夹。你可以在 " -"``venv/var/flaskr-instance`` 找到它。" - -#: ../../tutorial/deploy.rst:80 -msgid "Configure the Secret Key" -msgstr "配置密钥" - -#: ../../tutorial/deploy.rst:82 -msgid "" -"In the beginning of the tutorial that you gave a default value for " -":data:`SECRET_KEY`. This should be changed to some random bytes in " -"production. Otherwise, attackers could use the public ``'dev'`` key to " -"modify the session cookie, or anything else that uses the secret key." -msgstr "" -"在这个教程的一开始,你为 :data:`SECRET_KEY` 设置了一个默认值。在生产环境中,它" -"应该被更换为一个随机字节串。否则,攻击者可以使用常用的 ``'dev'`` 密钥去修改会话 " - -"cookie,或是其他任何使用密钥的数据。" - -#: ../../tutorial/deploy.rst:87 -msgid "You can use the following command to output a random secret key:" -msgstr "你可以使用下面的命令生成一个随机密钥:" - -#: ../../tutorial/deploy.rst:95 -msgid "" -"Create the ``config.py`` file in the instance folder, which the factory " -"will read from if it exists. Copy the generated value into it." -msgstr "" -"在实例文件夹中创建 ``config.py`` 文件,如果这个文件存在,程序工厂将会从它读取配置。" -"把生成的值复制进去:" - -#: ../../tutorial/deploy.rst:98 -msgid "``venv/var/flaskr-instance/config.py``" -msgstr "``venv/var/flaskr-instance/config.py``" - -#: ../../tutorial/deploy.rst:103 -msgid "" -"You can also set any other necessary configuration here, although " -"``SECRET_KEY`` is the only one needed for Flaskr." -msgstr "" -"你也可以在这里设置任意其他必要的配置,尽管对于 Flaskr 来说 ``SECRET_KEY`` 是唯一需要的配置。" - -#: ../../tutorial/deploy.rst:108 -msgid "Run with a Production Server" -msgstr "使用生产服务器运行应用" - -#: ../../tutorial/deploy.rst:110 -msgid "" -"When running publicly rather than in development, you should not use the " -"built-in development server (``flask run``). The development server is " -"provided by Werkzeug for convenience, but is not designed to be " -"particularly efficient, stable, or secure." -msgstr "" -"当在生产环境下运行时,你不应该使用内置的开发服务器(``flask run``)。开发服务器由 " -"Werkzeug 提供,它被设计用来让你在开发时更加方便,因此并不是特别高效、稳定或安全。" - -#: ../../tutorial/deploy.rst:115 -msgid "" -"Instead, use a production WSGI server. For example, to use `Waitress`_, " -"first install it in the virtual environment:" -msgstr "" -"相反,请使用一个生产 WSGI 服务器。举例来说,要使用 `Waitress`_,首先在虚拟环境下安装它:" - -#: ../../tutorial/deploy.rst:122 -msgid "" -"You need to tell Waitress about your application, but it doesn't use " -"``FLASK_APP`` like ``flask run`` does. You need to tell it to import and " -"call the application factory to get an application object." -msgstr "" -"你需要告诉 Waitress 你的应用在哪里,但是它并不像 ``flask run`` 那样读取 ``FLASK_APP``。" -"你需要告诉它去导入并调用应用工厂来获取一个应用对象。" - -#: ../../tutorial/deploy.rst:132 -msgid "" -"See :doc:`/deploying/index` for a list of many different ways to host " -"your application. Waitress is just an example, chosen for the tutorial " -"because it supports both Windows and Linux. There are many more WSGI " -"servers and deployment options that you may choose for your project." -msgstr "" -"阅读 :doc:`/deploying/index` 了解托管应用的多种不同方式。Waitress 只是一个" -"示例,在这个教程里选择它是因为它同时支持 Windows 和 Linux。还有很多 WSGI 服务器" -"和部署选项可以供你的项目选择。" - -#: ../../tutorial/deploy.rst:139 -msgid "Continue to :doc:`next`." -msgstr "继续阅读 :doc:`next`。" +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2010 Pallets +# This file is distributed under the same license as the Flask package. +# Grey Li , 2021. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Flask 2.1.x\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Grey Li \n" +"Language-Team: zh_CN \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.9.1\n" + +#: ../../tutorial/deploy.rst:2 +msgid "Deploy to Production" +msgstr "部署到生产环境" + +#: ../../tutorial/deploy.rst:4 +msgid "" +"This part of the tutorial assumes you have a server that you want to " +"deploy your application to. It gives an overview of how to create the " +"distribution file and install it, but won't go into specifics about what " +"server or software to use. You can set up a new environment on your " +"development computer to try out the instructions below, but probably " +"shouldn't use it for hosting a real public application. See " +":doc:`/deploying/index` for a list of many different ways to host your " +"application." +msgstr "" +"这部分教程假设你有一台服务器,你想把程序部署上去。这一章会概括如何创建分发文件并安装它,但是不会涉及具体使用哪一种服务器或软件。你可以在你的开发电脑上设置一个新环境并尝试下面的操作说明,但可能不应该用它来托管一个真正的公开应用。参阅" +" :doc:`/deploying/index` 了解托管你的应用的多种不同方式。" + +#: ../../tutorial/deploy.rst:15 +msgid "Build and Install" +msgstr "构建和安装" + +#: ../../tutorial/deploy.rst:17 +msgid "" +"When you want to deploy your application elsewhere, you build a " +"distribution file. The current standard for Python distribution is the " +"*wheel* format, with the ``.whl`` extension. Make sure the wheel library " +"is installed first:" +msgstr "" +"当你想要在其他地方部署你的应用时,你要创建一个分发文件。目前 Python 分发的标准是 *wheel* 格式,它使用 ``.whl`` " +"后缀。首先确保 wheel 库已经被安装:" + +#: ../../tutorial/deploy.rst:26 +msgid "" +"Running ``setup.py`` with Python gives you a command line tool to issue " +"build-related commands. The ``bdist_wheel`` command will build a wheel " +"distribution file." +msgstr "" +"使用 Python 运行 ``setup.py`` 给你提供了一个包含构建相关命令的命令行工具。其中 ``bdist_wheel`` " +"命令将会构建一个 wheel 分发文件。" + +#: ../../tutorial/deploy.rst:34 +msgid "" +"You can find the file in ``dist/flaskr-1.0.0-py3-none-any.whl``. The file" +" name is in the format of {project name}-{version}-{python tag} -{abi " +"tag}-{platform tag}." +msgstr "" +"你可以在 ``dist/flaskr-1.0.0-py3-none-any.whl`` " +"找到这个文件。文件名的格式为:{项目名称}-{版本}-{python 标签} -{abi 标签}-{平台标签}。" + +#: ../../tutorial/deploy.rst:38 +msgid "" +"Copy this file to another machine, :ref:`set up a new virtualenv " +"`, then install the file with ``pip``." +msgstr "把这个文件复制到另一台机器,:ref:`设置一个新的虚拟环境 `,然后使用 ``pip`` 安装它。" + +#: ../../tutorial/deploy.rst:46 +msgid "Pip will install your project along with its dependencies." +msgstr "pip 会安装你的项目及其依赖。" + +#: ../../tutorial/deploy.rst:48 +msgid "" +"Since this is a different machine, you need to run ``init-db`` again to " +"create the database in the instance folder." +msgstr "由于这是一台不同的机器,你需要再次运行 ``init-db`` 命令在实例文件夹内创建数据库。" + +#: ../../tutorial/deploy.rst:53 +msgid "Bash" +msgstr "Bash" + +#: ../../tutorial/deploy.rst:60 +msgid "Fish" +msgstr "" + +#: ../../tutorial/deploy.rst:67 +msgid "CMD" +msgstr "CMD" + +#: ../../tutorial/deploy.rst:74 +msgid "Powershell" +msgstr "Powershell" + +#: ../../tutorial/deploy.rst:81 +msgid "" +"When Flask detects that it's installed (not in editable mode), it uses a " +"different directory for the instance folder. You can find it at " +"``venv/var/flaskr-instance`` instead." +msgstr "" +"当 Flask 检测到它已经被安装(不在可编辑模式下),它会使用一个不同的目录作为实例文件夹。你可以在 ``venv/var/flaskr-" +"instance`` 找到它。" + +#: ../../tutorial/deploy.rst:87 +msgid "Configure the Secret Key" +msgstr "配置密钥" + +#: ../../tutorial/deploy.rst:89 +msgid "" +"In the beginning of the tutorial that you gave a default value for " +":data:`SECRET_KEY`. This should be changed to some random bytes in " +"production. Otherwise, attackers could use the public ``'dev'`` key to " +"modify the session cookie, or anything else that uses the secret key." +msgstr "" +"在这个教程的一开始,你为 :data:`SECRET_KEY` " +"设置了一个默认值。在生产环境中,它应该被更换为一个随机字节串。否则,攻击者可以使用常用的 ``'dev'`` 密钥去修改会话 " +"cookie,或是其他任何使用密钥的数据。" + +#: ../../tutorial/deploy.rst:94 +msgid "You can use the following command to output a random secret key:" +msgstr "你可以使用下面的命令生成一个随机密钥:" + +#: ../../tutorial/deploy.rst:102 +msgid "" +"Create the ``config.py`` file in the instance folder, which the factory " +"will read from if it exists. Copy the generated value into it." +msgstr "在实例文件夹中创建 ``config.py`` 文件,如果这个文件存在,程序工厂将会从它读取配置。把生成的值复制进去:" + +#: ../../tutorial/deploy.rst:105 +msgid "``venv/var/flaskr-instance/config.py``" +msgstr "``venv/var/flaskr-instance/config.py``" + +#: ../../tutorial/deploy.rst:110 +msgid "" +"You can also set any other necessary configuration here, although " +"``SECRET_KEY`` is the only one needed for Flaskr." +msgstr "你也可以在这里设置任意其他必要的配置,尽管对于 Flaskr 来说 ``SECRET_KEY`` 是唯一需要的配置。" + +#: ../../tutorial/deploy.rst:115 +msgid "Run with a Production Server" +msgstr "使用生产服务器运行应用" + +#: ../../tutorial/deploy.rst:117 +msgid "" +"When running publicly rather than in development, you should not use the " +"built-in development server (``flask run``). The development server is " +"provided by Werkzeug for convenience, but is not designed to be " +"particularly efficient, stable, or secure." +msgstr "" +"当在生产环境下运行时,你不应该使用内置的开发服务器(``flask run``)。开发服务器由 Werkzeug " +"提供,它被设计用来让你在开发时更加方便,因此并不是特别高效、稳定或安全。" + +#: ../../tutorial/deploy.rst:122 +msgid "" +"Instead, use a production WSGI server. For example, to use `Waitress`_, " +"first install it in the virtual environment:" +msgstr "相反,请使用一个生产 WSGI 服务器。举例来说,要使用 `Waitress`_,首先在虚拟环境下安装它:" + +#: ../../tutorial/deploy.rst:129 +msgid "" +"You need to tell Waitress about your application, but it doesn't use " +"``FLASK_APP`` like ``flask run`` does. You need to tell it to import and " +"call the application factory to get an application object." +msgstr "" +"你需要告诉 Waitress 你的应用在哪里,但是它并不像 ``flask run`` 那样读取 " +"``FLASK_APP``。你需要告诉它去导入并调用应用工厂来获取一个应用对象。" + +#: ../../tutorial/deploy.rst:139 +msgid "" +"See :doc:`/deploying/index` for a list of many different ways to host " +"your application. Waitress is just an example, chosen for the tutorial " +"because it supports both Windows and Linux. There are many more WSGI " +"servers and deployment options that you may choose for your project." +msgstr "" +"阅读 :doc:`/deploying/index` 了解托管应用的多种不同方式。Waitress " +"只是一个示例,在这个教程里选择它是因为它同时支持 Windows 和 Linux。还有很多 WSGI 服务器和部署选项可以供你的项目选择。" + +#: ../../tutorial/deploy.rst:146 +msgid "Continue to :doc:`next`." +msgstr "继续阅读 :doc:`next`。" diff --git a/docs/locales/zh_CN/LC_MESSAGES/tutorial/factory.po b/docs/locales/zh_CN/LC_MESSAGES/tutorial/factory.po index b557ea545..0219744b0 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/tutorial/factory.po +++ b/docs/locales/zh_CN/LC_MESSAGES/tutorial/factory.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Grey Li \n" "Language-Team: zh_CN \n" @@ -26,9 +26,7 @@ msgid "" "A Flask application is an instance of the :class:`Flask` class. " "Everything about the application, such as configuration and URLs, will be" " registered with this class." -msgstr "" -"Flask 应用是 :class:`Flask` 类的实例。关于这个应用的一切,比如配置和 URL," -"都会使用这个类注册。" +msgstr "Flask 应用是 :class:`Flask` 类的实例。关于这个应用的一切,比如配置和 URL,都会使用这个类注册。" #: ../../tutorial/factory.rst:10 msgid "" @@ -38,9 +36,8 @@ msgid "" " simple and useful in some cases, it can cause some tricky issues as the " "project grows." msgstr "" -"创建一个 Flask 应用最直接的方式是直接在你的代码顶部创建一个全局的 :class:`Flask` " -"实例,就像上一页的“Hello, World!”示例做的那样。虽然这在某些情况下很简单也很有用," -"但它在项目变大时会带来一些棘手的问题。" +"创建一个 Flask 应用最直接的方式是直接在你的代码顶部创建一个全局的 :class:`Flask` 实例,就像上一页的“Hello, " +"World!”示例做的那样。虽然这在某些情况下很简单也很有用,但它在项目变大时会带来一些棘手的问题。" #: ../../tutorial/factory.rst:16 msgid "" @@ -51,8 +48,7 @@ msgid "" "will be returned." msgstr "" "与其全局创建一个 :class:`Flask` 类实例,不如在一个函数里创建它。这个函数被称为 " -"*应用工厂*。应用所需要的任何配置、注册和其他设置都将在这个函数里进行,然后应用" -"会被返回。" +"*应用工厂*。应用所需要的任何配置、注册和其他设置都将在这个函数里进行,然后应用会被返回。" #: ../../tutorial/factory.rst:24 msgid "The Application Factory" @@ -67,7 +63,6 @@ msgid "" msgstr "" "是时候开始写代码了!创建 ``flaskr`` 目录并添加 ``__init__.py`` 文件。``__init__.py`` " "有两个作用:它将包含应用工厂,而且告诉 Python,``flaskr`` 目录应该被看做一个包。" -"" #: ../../tutorial/factory.rst:35 msgid "``flaskr/__init__.py``" @@ -77,9 +72,7 @@ msgstr "``flaskr/__init__.py``" msgid "" "``create_app`` is the application factory function. You'll add to it " "later in the tutorial, but it already does a lot." -msgstr "" -"``create_app`` 是应用工厂函数。你会在教程后面对它进行补充,不过它已经" -"做了很多事情。" +msgstr "``create_app`` 是应用工厂函数。你会在教程后面对它进行补充,不过它已经做了很多事情。" #: ../../tutorial/factory.rst:74 msgid "" @@ -95,8 +88,8 @@ msgid "" "know where it's located to set up some paths, and ``__name__`` is a " "convenient way to tell it that." msgstr "" -"``__name__`` 是当前 Python 模块的名称。为了设置一些路径,应用需要知道它的位置,而 " -"``__name__`` 是告诉它当前位置的一个便捷方式。" +"``__name__`` 是当前 Python 模块的名称。为了设置一些路径,应用需要知道它的位置,而 ``__name__`` " +"是告诉它当前位置的一个便捷方式。" #: ../../tutorial/factory.rst:81 msgid "" @@ -106,17 +99,15 @@ msgid "" "local data that shouldn't be committed to version control, such as " "configuration secrets and the database file." msgstr "" -"``instance_relative_config=True`` 用来告诉应用,配置文件的位置相对于 " -":ref:`实例文件夹 `。实例文件夹位于 ``flaskr`` 包的外层,它" -"用来存放不应该提交到版本控制软件的本地数据,比如包含私密信息的配置和数据库文件。" +"``instance_relative_config=True`` 用来告诉应用,配置文件的位置相对于 :ref:`实例文件夹 " +"`。实例文件夹位于 ``flaskr`` " +"包的外层,它用来存放不应该提交到版本控制软件的本地数据,比如包含私密信息的配置和数据库文件。" #: ../../tutorial/factory.rst:88 msgid "" ":meth:`app.config.from_mapping() ` sets some default" " configuration that the app will use:" -msgstr "" -":meth:`app.config.from_mapping() ` 设置一些应用将会使用的" -"默认配置:" +msgstr ":meth:`app.config.from_mapping() ` 设置一些应用将会使用的默认配置:" #: ../../tutorial/factory.rst:91 msgid "" @@ -124,8 +115,8 @@ msgid "" "It's set to ``'dev'`` to provide a convenient value during development, " "but it should be overridden with a random value when deploying." msgstr "" -":data:`SECRET_KEY` 被 Flask 和扩展用来保持数据安全。为了方便,在开发时可以将它" -"设为 ``'dev'``,但是它在部署时应该被一个随机值覆写。" +":data:`SECRET_KEY` 被 Flask 和扩展用来保持数据安全。为了方便,在开发时可以将它设为 " +"``'dev'``,但是它在部署时应该被一个随机值覆写。" #: ../../tutorial/factory.rst:96 msgid "" @@ -134,9 +125,8 @@ msgid "" "path that Flask has chosen for the instance folder. You'll learn more " "about the database in the next section." msgstr "" -"``DATABASE`` 是保存 SQLite 数据库文件的路径。它在 " -":attr:`app.instance_path ` 路径下,这是 Flask 为实例" -"文件夹选择的路径。你会在下一节了解到更多关于数据库的内容。" +"``DATABASE`` 是保存 SQLite 数据库文件的路径。它在 :attr:`app.instance_path " +"` 路径下,这是 Flask 为实例文件夹选择的路径。你会在下一节了解到更多关于数据库的内容。" #: ../../tutorial/factory.rst:102 msgid "" @@ -145,9 +135,8 @@ msgid "" "the instance folder if it exists. For example, when deploying, this can " "be used to set a real ``SECRET_KEY``." msgstr "" -"如果实例文件夹里存在 ``config.py`` 文件," -":meth:`app.config.from_pyfile() ` 会使用从这个文件中" -"获取到的值来覆写默认配置。例如,当部署时,这可以被用来设置一个真正的 " +"如果实例文件夹里存在 ``config.py`` 文件,:meth:`app.config.from_pyfile() " +"` 会使用从这个文件中获取到的值来覆写默认配置。例如,当部署时,这可以被用来设置一个真正的 " "``SECRET_KEY`` 配置值。" #: ../../tutorial/factory.rst:107 @@ -157,9 +146,8 @@ msgid "" "later in the tutorial can be configured independently of any development " "values you have configured." msgstr "" -"``test_config`` 也可以传递给工厂函数,这时传入的测试配置会被使用,而不是" -"实例文件夹内的配置。这样可以让你在稍后的教程中会编写的测试被独立配置,以区别" -"于任何开发时使用的值。" +"``test_config`` " +"也可以传递给工厂函数,这时传入的测试配置会被使用,而不是实例文件夹内的配置。这样可以让你在稍后的教程中会编写的测试被独立配置,以区别于任何开发时使用的值。" #: ../../tutorial/factory.rst:112 msgid "" @@ -169,8 +157,7 @@ msgid "" "create the SQLite database file there." msgstr "" ":func:`os.makedirs` 确保 :attr:`app.instance_path ` " -"指向的路径存在。Flask 不会自动创建实例文件夹,但它需要被创建,因为你的项目将在" -"那里创建 SQLite 数据库文件。" +"指向的路径存在。Flask 不会自动创建实例文件夹,但它需要被创建,因为你的项目将在那里创建 SQLite 数据库文件。" #: ../../tutorial/factory.rst:118 msgid "" @@ -179,9 +166,9 @@ msgid "" "creates a connection between the URL ``/hello`` and a function that " "returns a response, the string ``'Hello, World!'`` in this case." msgstr "" -":meth:`@app.route() ` 创建了一个简单的路由,这样在开始下面的教程" -"之前你可以看到应用能够正常工作。它在 URL ``/hello`` 和一个函数之间创建了一个" -"连接,这个函数会返回一个响应,在这里即 ``'Hello, World!'`` 字符串。" +":meth:`@app.route() ` " +"创建了一个简单的路由,这样在开始下面的教程之前你可以看到应用能够正常工作。它在 URL ``/hello`` " +"和一个函数之间创建了一个连接,这个函数会返回一个响应,在这里即 ``'Hello, World!'`` 字符串。" #: ../../tutorial/factory.rst:126 msgid "Run The Application" @@ -194,9 +181,8 @@ msgid "" "development mode. Remember, you should still be in the top-level ``flask-" "tutorial`` directory, not the ``flaskr`` package." msgstr "" -"现在你可以用 ``flask`` 命令运行应用。在终端里告诉 Flask 要去哪里找到你的应用,然后" -"以开发模式运行它。请记住,你应该仍然在顶层的 ``flask-tutorial`` 目录下,而不是 " -"``flaskr`` 包内。" +"现在你可以用 ``flask`` 命令运行应用。在终端里告诉 Flask 要去哪里找到你的应用,然后以开发模式运行它。请记住,你应该仍然在顶层的 " +"``flask-tutorial`` 目录下,而不是 ``flaskr`` 包内。" #: ../../tutorial/factory.rst:133 msgid "" @@ -204,36 +190,44 @@ msgid "" "exception, and restarts the server whenever you make changes to the code." " You can leave it running and just reload the browser page as you follow " "the tutorial." -msgstr "" -"在开发模式下,每当页面抛出一个异常时,就会显示一个交互式的调试器(debugger);每当" -"你对代码进行修改,就会重启服务器。在接下来的教程中,你可以让它保持运行,只需要重载" -"浏览器页面。" +msgstr "在开发模式下,每当页面抛出一个异常时,就会显示一个交互式的调试器(debugger);每当你对代码进行修改,就会重启服务器。在接下来的教程中,你可以让它保持运行,只需要重载浏览器页面。" #: ../../tutorial/factory.rst:140 msgid "Bash" msgstr "Bash" #: ../../tutorial/factory.rst:148 +msgid "Fish" +msgstr "" + +#: ../../tutorial/factory.rst:156 msgid "CMD" msgstr "CMD" -#: ../../tutorial/factory.rst:156 +#: ../../tutorial/factory.rst:164 msgid "Powershell" msgstr "Powershell" -#: ../../tutorial/factory.rst:164 +#: ../../tutorial/factory.rst:172 msgid "You'll see output similar to this:" msgstr "你会看到类似下面的输出:" -#: ../../tutorial/factory.rst:176 +#: ../../tutorial/factory.rst:184 msgid "" "Visit http://127.0.0.1:5000/hello in a browser and you should see the " "\"Hello, World!\" message. Congratulations, you're now running your Flask" " web application!" msgstr "" -"在浏览器中访问 http://127.0.0.1:5000/hello,你应该会看到“Hello, World!”信息。" -"恭喜,你现在正在运行你的 Flask web 应用!" +"在浏览器中访问 http://127.0.0.1:5000/hello,你应该会看到“Hello, World!”信息。恭喜,你现在正在运行你的 " +"Flask web 应用!" + +#: ../../tutorial/factory.rst:188 +msgid "" +"If another program is already using port 5000, you'll see ``OSError: " +"[Errno 98]`` or ``OSError: [WinError 10013]`` when the server tries to " +"start. See :ref:`address-already-in-use` for how to handle that." +msgstr "" -#: ../../tutorial/factory.rst:180 +#: ../../tutorial/factory.rst:193 msgid "Continue to :doc:`database`." msgstr "继续阅读 :doc:`database`。" diff --git a/docs/locales/zh_CN/LC_MESSAGES/tutorial/index.po b/docs/locales/zh_CN/LC_MESSAGES/tutorial/index.po index f76f5e6d0..43ff9e515 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/tutorial/index.po +++ b/docs/locales/zh_CN/LC_MESSAGES/tutorial/index.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-30 19:27+0000\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Grey Li \n" "Language-Team: zh_CN \n" @@ -35,8 +35,8 @@ msgstr "" "这个教程会一步步带你创建一个基础的博客程序,它叫做 " "Flaskr。在这个程序里,用户将可以注册、登录、创建文章、编辑或删除文章。你还将会学习打包程序,这样就可以在其他电脑上安装这个程序。" -msgid "screenshot of index page" -msgstr "首页截图" +msgid "首页截图" +msgstr "" #: ../../tutorial/index.rst:30 msgid "" @@ -57,8 +57,8 @@ msgstr "" "Flask 可以做什么建立一个全局认识,然后深入其他文档了解更多内容。这个教程只使用了 Flask 和 Python " "提供的功能。在你开发的另一个项目里,你也许会想要使用 :doc:`/extensions` 或其他库让某些功能实现起来更简单。" -msgid "screenshot of login page" -msgstr "登录页截图" +msgid "登录页截图" +msgstr "" #: ../../tutorial/index.rst:47 msgid "" @@ -90,3 +90,9 @@ msgstr "" #: ../../tutorial/index.rst:64 msgid "Continue to :doc:`layout`." msgstr "下一节是 :doc:`layout`。" + +#~ msgid "screenshot of index page" +#~ msgstr "首页截图" + +#~ msgid "screenshot of login page" +#~ msgstr "登录页截图" diff --git a/docs/locales/zh_CN/LC_MESSAGES/tutorial/views.po b/docs/locales/zh_CN/LC_MESSAGES/tutorial/views.po index c67fc1651..800857f1f 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/tutorial/views.po +++ b/docs/locales/zh_CN/LC_MESSAGES/tutorial/views.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Grey Li \n" "Language-Team: zh_CN \n" @@ -29,9 +29,8 @@ msgid "" "an outgoing response. Flask can also go the other direction and generate " "a URL to a view based on its name and arguments." msgstr "" -"视图函数是你编写用来回应发送到应用的请求的代码。Flask 使用模式来匹配传入的请求 URL 到应该" -"处理它的视图。视图返回的数据会被 Flask 转换为发出的响应。Flask 也可以重定向到其他视图并" -"根据视图名称和参数生成到某一个视图的 URL。" +"视图函数是你编写用来回应发送到应用的请求的代码。Flask 使用模式来匹配传入的请求 URL 到应该处理它的视图。视图返回的数据会被 Flask " +"转换为发出的响应。Flask 也可以重定向到其他视图并根据视图名称和参数生成到某一个视图的 URL。" #: ../../tutorial/views.rst:14 msgid "Create a Blueprint" @@ -44,9 +43,7 @@ msgid "" " application, they are registered with a blueprint. Then the blueprint is" " registered with the application when it is available in the factory " "function." -msgstr "" -"蓝图(:class:`Blueprint`)是一种组织一组相关视图和其他代码的方式。视图和其他代码注册到" -"蓝图,而不是直接注册到应用上。然后,在工厂函数中应用可用时,蓝图会被注册到应用。" +msgstr "蓝图(:class:`Blueprint`)是一种组织一组相关视图和其他代码的方式。视图和其他代码注册到蓝图,而不是直接注册到应用上。然后,在工厂函数中应用可用时,蓝图会被注册到应用。" #: ../../tutorial/views.rst:22 msgid "" @@ -55,12 +52,12 @@ msgid "" "separate module. Since the blog needs to know about authentication, " "you'll write the authentication one first." msgstr "" -"Flaskr 将会有两个蓝图,一个用于认证相关的函数,一个用于博客帖子相关的函数。每一个蓝图的代码" -"将存放在单独的模块中。因为博客需要使用认证功能,所以你要先编写认证蓝图。" +"Flaskr " +"将会有两个蓝图,一个用于认证相关的函数,一个用于博客帖子相关的函数。每一个蓝图的代码将存放在单独的模块中。因为博客需要使用认证功能,所以你要先编写认证蓝图。" #: ../../tutorial/views.rst:27 ../../tutorial/views.rst:79 -#: ../../tutorial/views.rst:171 ../../tutorial/views.rst:218 -#: ../../tutorial/views.rst:247 ../../tutorial/views.rst:263 +#: ../../tutorial/views.rst:170 ../../tutorial/views.rst:222 +#: ../../tutorial/views.rst:251 ../../tutorial/views.rst:267 msgid "``flaskr/auth.py``" msgstr "``flaskr/auth.py``" @@ -71,9 +68,8 @@ msgid "" "is passed as the second argument. The ``url_prefix`` will be prepended to" " all the URLs associated with the blueprint." msgstr "" -"这会创建一个名为 ``'auth'`` 的 :class:`Blueprint`。和应用对象类似,蓝图需要知道它在" -"哪里被定义,所以 ``__name__`` 作为第二个参数传入。``url_prefix`` 将会被添加到所有和" -"这个蓝图相关的 URL 前。" +"这会创建一个名为 ``'auth'`` 的 :class:`Blueprint`。和应用对象类似,蓝图需要知道它在哪里被定义,所以 " +"``__name__`` 作为第二个参数传入。``url_prefix`` 将会被添加到所有和这个蓝图相关的 URL 前。" #: ../../tutorial/views.rst:46 msgid "" @@ -105,9 +101,8 @@ msgid "" "the form, it will validate their input and either show the form again " "with an error message or create the new user and go to the login page." msgstr "" -"当用户访问 URL ``/auth/register`` 时,``register`` 视图会返回 `HTML`_,其中包含" -"一个让他们填写的表单。当他们提交表单时,它会验证他们的输入,并且要么再次显示表单和" -"一个错误消息,要么创建新用户并跳转到登录页面。" +"当用户访问 URL ``/auth/register`` 时,``register`` 视图会返回 " +"`HTML`_,其中包含一个让他们填写的表单。当他们提交表单时,它会验证他们的输入,并且要么再次显示表单和一个错误消息,要么创建新用户并跳转到登录页面。" #: ../../tutorial/views.rst:76 msgid "" @@ -135,8 +130,8 @@ msgid "" "If the user submitted the form, :attr:`request.method ` " "will be ``'POST'``. In this case, start validating the input." msgstr "" -"如果用户提交了表单,:attr:`request.method ` 会是 ``'POST'``。" -"在这种情况下,视图开始验证输入的数据。" +"如果用户提交了表单,:attr:`request.method ` 会是 " +"``'POST'``。在这种情况下,视图开始验证输入的数据。" #: ../../tutorial/views.rst:122 msgid "" @@ -144,52 +139,49 @@ msgid "" "mapping submitted form keys and values. The user will input their " "``username`` and ``password``." msgstr "" -":attr:`request.form ` 是一个特殊类型的 :class:`dict`,它映射提交的" -"表单键到相应的值。用户将会输入他们的 ``username`` 和 ``password``。" +":attr:`request.form ` 是一个特殊类型的 " +":class:`dict`,它映射提交的表单键到相应的值。用户将会输入他们的 ``username`` 和 ``password``。" #: ../../tutorial/views.rst:126 msgid "Validate that ``username`` and ``password`` are not empty." msgstr "验证 ``username`` 和 ``password`` 不为空。" #: ../../tutorial/views.rst:128 -msgid "" -"Validate that ``username`` is not already registered by querying the " -"database and checking if a result is returned. :meth:`db.execute " -"` takes a SQL query with ``?`` placeholders " -"for any user input, and a tuple of values to replace the placeholders " -"with. The database library will take care of escaping the values so you " -"are not vulnerable to a *SQL injection attack*." +msgid "If validation succeeds, insert the new user data into the database." msgstr "" -"通过查询数据库并检查是否有结果返回,验证 ``username`` 是否已经被注册。" -":meth:`db.execute ` 接受一个 SQL 查询,其中包含" -"代表任意用户输入的 ``?`` 占位符,以及一个用来替换占位符的数据元组。数据库相关的库" -"将负责转义值,使得你不易受到 *SQL 注入攻击*。 -#: ../../tutorial/views.rst:136 +#: ../../tutorial/views.rst:130 +#, fuzzy msgid "" -":meth:`~sqlite3.Cursor.fetchone` returns one row from the query. If the " -"query returned no results, it returns ``None``. Later, " -":meth:`~sqlite3.Cursor.fetchall` is used, which returns a list of all " -"results." +":meth:`db.execute ` takes a SQL query with " +"``?`` placeholders for any user input, and a tuple of values to replace " +"the placeholders with. The database library will take care of escaping " +"the values so you are not vulnerable to a *SQL injection attack*." msgstr "" -":meth:`~sqlite3.Cursor.fetchone` 从查询返回一行。如果查询没有返回结果,它返回 ``None``。" -"接着,:meth:`~sqlite3.Cursor.fetchall` 被使用,它返回一个包含所有结果的列表。" +"通过查询数据库并检查是否有结果返回,验证 ``username`` 是否已经被注册。:meth:`db.execute " +"` 接受一个 SQL 查询,其中包含代表任意用户输入的 ``?`` " +"占位符,以及一个用来替换占位符的数据元组。数据库相关的库将负责转义值,使得你不易受到 *SQL 注入攻击*" -#: ../../tutorial/views.rst:141 +#: ../../tutorial/views.rst:136 +#, fuzzy msgid "" -"If validation succeeds, insert the new user data into the database. For " -"security, passwords should never be stored in the database directly. " +"For security, passwords should never be stored in the database directly. " "Instead, :func:`~werkzeug.security.generate_password_hash` is used to " "securely hash the password, and that hash is stored. Since this query " "modifies data, :meth:`db.commit() ` needs to " "be called afterwards to save the changes." msgstr "" -"如果验证成功,插入新的用户数据到数据库。为了安全起见,密码绝对不应该直接存储到数据库中。" -"相反,:func:`~werkzeug.security.generate_password_hash` 被用来安全地计算出密码散列值," -"并存储该散列值。因为这个查询修改了数据,为了保存变动,:meth:`db.commit() ` " -"需要在之后被调用。" +"如果验证成功,插入新的用户数据到数据库。为了安全起见,密码绝对不应该直接存储到数据库中。相反,:func:`~werkzeug.security.generate_password_hash`" +" 被用来安全地计算出密码散列值,并存储该散列值。因为这个查询修改了数据,为了保存变动,:meth:`db.commit() " +"` 需要在之后被调用。" + +#: ../../tutorial/views.rst:144 +msgid "" +"An :exc:`sqlite3.IntegrityError` will occur if the username already " +"exists, which should be shown to the user as another validation error." +msgstr "" -#: ../../tutorial/views.rst:149 +#: ../../tutorial/views.rst:148 msgid "" "After storing the user, they are redirected to the login page. " ":func:`url_for` generates the URL for the login view based on its name. " @@ -197,55 +189,63 @@ msgid "" " the URL later without changing all code that links to it. " ":func:`redirect` generates a redirect response to the generated URL." msgstr "" -"保存用户后,他们被重定向到登录页面。:func:`url_for` 根据其名称生成到 ``login`` 视图的 URL。" -"和直接写出来 URL 相比,这是更推荐的做法,因为它允许你以后轻松更改 URL 而不用更新所有链接到它" -"的代码。:func:`redirect` 生成一个重定向响应到生成的 URL。" +"保存用户后,他们被重定向到登录页面。:func:`url_for` 根据其名称生成到 ``login`` 视图的 URL。和直接写出来 URL " +"相比,这是更推荐的做法,因为它允许你以后轻松更改 URL 而不用更新所有链接到它的代码。:func:`redirect` " +"生成一个重定向响应到生成的 URL。" -#: ../../tutorial/views.rst:156 +#: ../../tutorial/views.rst:155 msgid "" "If validation fails, the error is shown to the user. :func:`flash` stores" " messages that can be retrieved when rendering the template." -msgstr "" -"如果验证失败,错误会显示给用户。:func:`flash` 会存储消息,这些消息可以在渲染模板时被" -"获取。" +msgstr "如果验证失败,错误会显示给用户。:func:`flash` 会存储消息,这些消息可以在渲染模板时被获取。" -#: ../../tutorial/views.rst:159 +#: ../../tutorial/views.rst:158 msgid "" "When the user initially navigates to ``auth/register``, or there was a " "validation error, an HTML page with the registration form should be " "shown. :func:`render_template` will render a template containing the " "HTML, which you'll write in the next step of the tutorial." msgstr "" -"当用户最初导航到 ``auth/register`` 时,或是有验证错误时,应该显示一个带有注册表单的 " -"HTML 页面。:func:`render_template` 将渲染一个包含该 HTML 页面的模板,你将在教程" -"的下一章编写相关代码。" +"当用户最初导航到 ``auth/register`` 时,或是有验证错误时,应该显示一个带有注册表单的 HTML " +"页面。:func:`render_template` 将渲染一个包含该 HTML 页面的模板,你将在教程的下一章编写相关代码。" -#: ../../tutorial/views.rst:167 +#: ../../tutorial/views.rst:166 msgid "Login" msgstr "登录" -#: ../../tutorial/views.rst:169 +#: ../../tutorial/views.rst:168 msgid "This view follows the same pattern as the ``register`` view above." msgstr "这个视图和上面的 ``register`` 视图遵循相同的模式。" -#: ../../tutorial/views.rst:199 +#: ../../tutorial/views.rst:198 msgid "There are a few differences from the ``register`` view:" msgstr "和 ``register`` 视图有一些区别:" -#: ../../tutorial/views.rst:201 +#: ../../tutorial/views.rst:200 msgid "The user is queried first and stored in a variable for later use." msgstr "首先查询用户,并存储到一个变量供后面使用。" -#: ../../tutorial/views.rst:203 +#: ../../tutorial/views.rst:202 +#, fuzzy +msgid "" +":meth:`~sqlite3.Cursor.fetchone` returns one row from the query. If the " +"query returned no results, it returns ``None``. Later, " +":meth:`~sqlite3.Cursor.fetchall` will be used, which returns a list of " +"all results." +msgstr "" +":meth:`~sqlite3.Cursor.fetchone` 从查询返回一行。如果查询没有返回结果,它返回 " +"``None``。接着,:meth:`~sqlite3.Cursor.fetchall` 被使用,它返回一个包含所有结果的列表。" + +#: ../../tutorial/views.rst:207 msgid "" ":func:`~werkzeug.security.check_password_hash` hashes the submitted " "password in the same way as the stored hash and securely compares them. " "If they match, the password is valid." msgstr "" -":func:`~werkzeug.security.check_password_hash` 以存储散列值时相同的方式为提交的" -"密码计算散列值,并对它们进行安全对比。如果匹配,则密码是有效的。" +":func:`~werkzeug.security.check_password_hash` " +"以存储散列值时相同的方式为提交的密码计算散列值,并对它们进行安全对比。如果匹配,则密码是有效的。" -#: ../../tutorial/views.rst:207 +#: ../../tutorial/views.rst:211 msgid "" ":data:`session` is a :class:`dict` that stores data across requests. When" " validation succeeds, the user's ``id`` is stored in a new session. The " @@ -253,21 +253,21 @@ msgid "" " then sends it back with subsequent requests. Flask securely *signs* the " "data so that it can't be tampered with." msgstr "" -":data:`session` 是一个 :class:`dict`,用来存储跨请求的数据。当验证成功,用户的 ``id`` 被" -"存储到一个新的 session。数据被存储到一个发送给浏览器的 *cookie* 中,然后浏览器会在后续的请求中" -"把它发送回来。Flask 对数据进行安全 *签名*,使其无法被篡改。" +":data:`session` 是一个 :class:`dict`,用来存储跨请求的数据。当验证成功,用户的 ``id`` 被存储到一个新的 " +"session。数据被存储到一个发送给浏览器的 *cookie* 中,然后浏览器会在后续的请求中把它发送回来。Flask 对数据进行安全 " +"*签名*,使其无法被篡改。" -#: ../../tutorial/views.rst:213 +#: ../../tutorial/views.rst:217 msgid "" "Now that the user's ``id`` is stored in the :data:`session`, it will be " "available on subsequent requests. At the beginning of each request, if a " "user is logged in their information should be loaded and made available " "to other views." msgstr "" -"现在,用户的 ``id`` 被存储到 :data:`session` 中,它将会在后续的请求中可用。在每一个" -"请求开始时,如果用户已经登录,他们的信息应该被加载并提供给其他视图。" +"现在,用户的 ``id`` 被存储到 :data:`session` " +"中,它将会在后续的请求中可用。在每一个请求开始时,如果用户已经登录,他们的信息应该被加载并提供给其他视图。" -#: ../../tutorial/views.rst:232 +#: ../../tutorial/views.rst:236 msgid "" ":meth:`bp.before_app_request() ` registers " "a function that runs before the view function, no matter what URL is " @@ -277,54 +277,48 @@ msgid "" "there is no user id, or if the id doesn't exist, ``g.user`` will be " "``None``." msgstr "" -":meth:`bp.before_app_request() ` 注册一个函数并" -"让它在每一个视图函数之前运行,不管请求发到哪一个 URL。``load_logged_in_user`` 检查" -"用户的 ID 是否存储在 :data:`session` 中,并从数据库中获取对应用户的数据,将其存储到 " -":data:`g.user ` 上——它存在于单个请求的生命周期内。如果没有用户 ID,或是 ID 不存在," -"``g.user`` 将是 ``None``。" +":meth:`bp.before_app_request() ` " +"注册一个函数并让它在每一个视图函数之前运行,不管请求发到哪一个 URL。``load_logged_in_user`` 检查用户的 ID " +"是否存储在 :data:`session` 中,并从数据库中获取对应用户的数据,将其存储到 :data:`g.user ` " +"上——它存在于单个请求的生命周期内。如果没有用户 ID,或是 ID 不存在,``g.user`` 将是 ``None``。" -#: ../../tutorial/views.rst:242 +#: ../../tutorial/views.rst:246 msgid "Logout" msgstr "登出" -#: ../../tutorial/views.rst:244 +#: ../../tutorial/views.rst:248 msgid "" "To log out, you need to remove the user id from the :data:`session`. Then" " ``load_logged_in_user`` won't load a user on subsequent requests." msgstr "" -"若要登出,你需要从 :data:`session` 中移除用户 ID。这样 ``load_logged_in_user`` 就不会" -"在后续请求中加载用户。" +"若要登出,你需要从 :data:`session` 中移除用户 ID。这样 ``load_logged_in_user`` " +"就不会在后续请求中加载用户。" -#: ../../tutorial/views.rst:257 +#: ../../tutorial/views.rst:261 msgid "Require Authentication in Other Views" msgstr "在其他视图里要求认证" -#: ../../tutorial/views.rst:259 +#: ../../tutorial/views.rst:263 msgid "" "Creating, editing, and deleting blog posts will require a user to be " "logged in. A *decorator* can be used to check this for each view it's " "applied to." -msgstr "" -"创建、编辑和删除博客帖子将需要用户登录才能操作。可以使用一个 *装饰器* 来为每一个使用它的" -"视图检查登录状态。" +msgstr "创建、编辑和删除博客帖子将需要用户登录才能操作。可以使用一个 *装饰器* 来为每一个使用它的视图检查登录状态。" -#: ../../tutorial/views.rst:276 +#: ../../tutorial/views.rst:280 msgid "" "This decorator returns a new view function that wraps the original view " "it's applied to. The new function checks if a user is loaded and " "redirects to the login page otherwise. If a user is loaded the original " "view is called and continues normally. You'll use this decorator when " "writing the blog views." -msgstr "" -"这个装饰器返回一个新的视图函数,它包裹了被装饰的原始视图函数。新的函数会检查是否有用户被加载:" -"如果有用户被加载,则会调用原视图继续正常运行,否则会重定向到登录页面。你会在写博客视图时使用" -"这个装饰器。" +msgstr "这个装饰器返回一个新的视图函数,它包裹了被装饰的原始视图函数。新的函数会检查是否有用户被加载:如果有用户被加载,则会调用原视图继续正常运行,否则会重定向到登录页面。你会在写博客视图时使用这个装饰器。" -#: ../../tutorial/views.rst:283 +#: ../../tutorial/views.rst:287 msgid "Endpoints and URLs" msgstr "端点和 URL" -#: ../../tutorial/views.rst:285 +#: ../../tutorial/views.rst:289 msgid "" "The :func:`url_for` function generates the URL to a view based on a name " "and arguments. The name associated with a view is also called the " @@ -334,27 +328,27 @@ msgstr "" ":func:`url_for` 函数根据视图名称和参数生成到一个视图的 URL。视图的名称也被叫做 " "*端点(endpoint)*,默认情况下,它和视图函数的名称相同。" -#: ../../tutorial/views.rst:290 +#: ../../tutorial/views.rst:294 msgid "" "For example, the ``hello()`` view that was added to the app factory " "earlier in the tutorial has the name ``'hello'`` and can be linked to " "with ``url_for('hello')``. If it took an argument, which you'll see " "later, it would be linked to using ``url_for('hello', who='World')``." msgstr "" -"例如,在教程的前面部分,``hello()`` 视图被添加到应用工厂,这个视图的名称是 ``'hello'``," -"可以通过 ``url_for('hello')`` 生成指向它的 URL。如果它接受一个参数(后面你会看到),那" -"么生成 URL 的方式则会是 ``url_for('hello', who='World')``。" +"例如,在教程的前面部分,``hello()`` 视图被添加到应用工厂,这个视图的名称是 ``'hello'``,可以通过 " +"``url_for('hello')`` 生成指向它的 URL。如果它接受一个参数(后面你会看到),那么生成 URL 的方式则会是 " +"``url_for('hello', who='World')``。" -#: ../../tutorial/views.rst:296 +#: ../../tutorial/views.rst:300 msgid "" "When using a blueprint, the name of the blueprint is prepended to the " "name of the function, so the endpoint for the ``login`` function you " "wrote above is ``'auth.login'`` because you added it to the ``'auth'`` " "blueprint." msgstr "" -"当使用蓝图时,蓝图的名称会被插入到视图函数的名称前,所以你上面写的 ``login`` 函数" -"的端点是 ``'auth.login'``,因为你把它添加到了 ``'auth'`` 蓝图。" +"当使用蓝图时,蓝图的名称会被插入到视图函数的名称前,所以你上面写的 ``login`` 函数的端点是 " +"``'auth.login'``,因为你把它添加到了 ``'auth'`` 蓝图。" -#: ../../tutorial/views.rst:301 +#: ../../tutorial/views.rst:305 msgid "Continue to :doc:`templates`." msgstr "继续阅读 :doc:`templates`。" diff --git a/docs/locales/zh_CN/LC_MESSAGES/views.po b/docs/locales/zh_CN/LC_MESSAGES/views.po index d4a55ee86..a65bf53aa 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/views.po +++ b/docs/locales/zh_CN/LC_MESSAGES/views.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Flask 2.1.x\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-25 19:31+0800\n" +"POT-Creation-Date: 2022-06-12 19:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: zh_CN \n" @@ -99,8 +99,8 @@ msgstr "" msgid "" "For RESTful APIs it's especially helpful to execute a different function " "for each HTTP method. With the :class:`flask.views.MethodView` you can " -"easily do that. Each HTTP method maps to a function with the same name " -"(just in lowercase)::" +"easily do that. Each HTTP method maps to a method of the class with the " +"same name (just in lowercase)::" msgstr "" #: ../../views.rst:133 @@ -227,3 +227,13 @@ msgid "" "If you have a lot of APIs that look similar you can refactor that " "registration code::" msgstr "" + +#~ msgid "" +#~ "For RESTful APIs it's especially helpful" +#~ " to execute a different function for" +#~ " each HTTP method. With the " +#~ ":class:`flask.views.MethodView` you can easily " +#~ "do that. Each HTTP method maps to" +#~ " a function with the same name " +#~ "(just in lowercase)::" +#~ msgstr "" diff --git a/docs/patterns/appfactories.rst b/docs/patterns/appfactories.rst index 79c78d602..a0e88ab3d 100644 --- a/docs/patterns/appfactories.rst +++ b/docs/patterns/appfactories.rst @@ -98,6 +98,13 @@ To run such an application, you can use the :command:`flask` command: $ export FLASK_APP=myapp $ flask run + .. group-tab:: Fish + + .. code-block:: text + + $ set -x FLASK_APP myapp + $ flask run + .. group-tab:: CMD .. code-block:: text @@ -124,6 +131,13 @@ in ``myapp``. You can also pass arguments to the factory like this: $ export FLASK_APP="myapp:create_app('dev')" $ flask run + .. group-tab:: Fish + + .. code-block:: text + + $ set -x FLASK_APP "myapp:create_app('dev')" + $ flask run + .. group-tab:: CMD .. code-block:: text diff --git a/docs/patterns/celery.rst b/docs/patterns/celery.rst index e1f6847e1..38a9a0252 100644 --- a/docs/patterns/celery.rst +++ b/docs/patterns/celery.rst @@ -64,7 +64,7 @@ An example task Let's write a task that adds two numbers together and returns the result. We configure Celery's broker and backend to use Redis, create a ``celery`` -application using the factor from above, and then use it to define the task. :: +application using the factory from above, and then use it to define the task. :: from flask import Flask diff --git a/docs/patterns/fileuploads.rst b/docs/patterns/fileuploads.rst index f24a43caf..304f57dcf 100644 --- a/docs/patterns/fileuploads.rst +++ b/docs/patterns/fileuploads.rst @@ -175,9 +175,8 @@ are JavaScript libraries like jQuery_ that have form plugins to ease the construction of progress bar. Because the common pattern for file uploads exists almost unchanged in all -applications dealing with uploads, there is also a Flask extension called -`Flask-Uploads`_ that implements a full fledged upload mechanism that -allows controlling which file extensions are allowed to be uploaded. +applications dealing with uploads, there are also some Flask extensions that +implement a full fledged upload mechanism that allows controlling which +file extensions are allowed to be uploaded. .. _jQuery: https://jquery.com/ -.. _Flask-Uploads: https://flask-uploads.readthedocs.io/en/latest/ diff --git a/docs/patterns/jquery.rst b/docs/patterns/jquery.rst index fafbdf182..0a75bb71a 100644 --- a/docs/patterns/jquery.rst +++ b/docs/patterns/jquery.rst @@ -23,8 +23,7 @@ to add a script statement to the bottom of your ```` to load jQuery: .. sourcecode:: html - + Another method is using Google's `AJAX Libraries API `_ to load jQuery: @@ -59,7 +58,7 @@ like this: .. sourcecode:: html+jinja - @@ -109,7 +108,7 @@ usually a better idea to have that in a separate script file: .. sourcecode:: html -