fix RST line too long
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Baumgold · committed by David Baumgold · parent c5c8bbc · Browse files · 15 files·+104 added−89 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
15 files+104 added−89 removed
- other:+104 added−89 removed
Provenance
- Commit
6606a4a- Tree
2d7d5b2- Author
David Baumgold <david@davidbaumgold.com>- Committer
David Baumgold <david@davidbaumgold.com>- Parent
c5c8bbc
15 files changed+104 added−89 removed
modified:docs/deploying/cgi.rst+3 added-3 removed
44 unmodified lines45 46 ScriptAlias /app /path/to/the/application.cgi47 48 On shared webhosting, though, you might not have access to your Apache config.49-In this case, a file called ``.htaccess``, sitting in the public directory you want50-your app to be available, works too but the ``ScriptAlias`` directive won't51-work in that case:49+In this case, a file called ``.htaccess``, sitting in the public directory50+you want your app to be available, works too but the ``ScriptAlias`` directive51+won't work in that case:52 53 .. sourcecode:: apache54 55 RewriteEngine On6 unmodified linesmodified:docs/deploying/fastcgi.rst+4 added-4 removed
2 unmodified lines3 FastCGI4 =======5 6 FastCGI is a deployment option on servers like `nginx`_, `lighttpd`_, and7-`cherokee`_; see :doc:`uwsgi` and :doc:`wsgi-standalone` for other options. To8-use your WSGI application with any of them you will need a FastCGI server first.9-The most popular one is `flup`_ which we will use for this guide. Make sure to10-have it installed to follow along.7+`cherokee`_; see :doc:`uwsgi` and :doc:`wsgi-standalone` for other options.8+To use your WSGI application with any of them you will need a FastCGI9+server first. The most popular one is `flup`_ which we will use for10+this guide. Make sure to have it installed to follow along.11 12 .. admonition:: Watch Out13 14 Please make sure in advance that any ``app.run()`` calls you might226 unmodified linesmodified:docs/deploying/mod_wsgi.rst+14 added-13 removed
50 unmodified lines51 52 Creating a `.wsgi` file53 -----------------------54 55-To run your application you need a :file:`yourapplication.wsgi` file. This file56-contains the code `mod_wsgi` is executing on startup to get the application57-object. The object called `application` in that file is then used as58-application.55+To run your application you need a :file:`yourapplication.wsgi` file.56+This file contains the code `mod_wsgi` is executing on startup57+to get the application object. The object called `application`58+in that file is then used as application.59 60 For most applications the following file should be sufficient::61 62 from yourapplication import app as application44 unmodified lines107 refuse to run with the above configuration. On a Windows system, eliminate those lines:108 109 .. sourcecode:: apache110 111- <VirtualHost *>112- ServerName example.com113- WSGIScriptAlias / C:\yourdir\yourapp.wsgi114- <Directory C:\yourdir>115- Order deny,allow116- Allow from all117- </Directory>118- </VirtualHost>111+ <VirtualHost *>112+ ServerName example.com113+ WSGIScriptAlias / C:\yourdir\yourapp.wsgi114+ <Directory C:\yourdir>115+ Order deny,allow116+ Allow from all117+ </Directory>118+ </VirtualHost>119 120-Note: There have been some changes in access control configuration for `Apache 2.4`_.120+Note: There have been some changes in access control configuration121+for `Apache 2.4`_.122 123 .. _Apache 2.4: https://httpd.apache.org/docs/trunk/upgrading.html124 125 Most notably, the syntax for directory permissions has changed from httpd 2.298 unmodified linesmodified:docs/deploying/uwsgi.rst+5 added-4 removed
29 unmodified lines30 .. sourcecode:: text31 32 $ uwsgi -s /tmp/yourapplication.sock --manage-script-name --mount /yourapplication=myapp:app33 34-The ``--manage-script-name`` will move the handling of ``SCRIPT_NAME`` to uwsgi,35-since it is smarter about that. It is used together with the ``--mount``36-directive which will make requests to ``/yourapplication`` be directed to37-``myapp:app``. If your application is accessible at root level, you can use a34+The ``--manage-script-name`` will move the handling of ``SCRIPT_NAME``35+to uwsgi, since it is smarter about that.36+It is used together with the ``--mount`` directive which will make37+requests to ``/yourapplication`` be directed to ``myapp:app``.38+If your application is accessible at root level, you can use a39 single ``/`` instead of ``/yourapplication``. ``myapp`` refers to the name of40 the file of your flask application (without extension) or the module which41 provides ``app``. ``app`` is the callable inside of your application (usually42 the line reads ``app = Flask(__name__)``.31 unmodified linesmodified:docs/advanced_foreword.rst+5 added-4 removed
6 unmodified lines7 ----------------------8 9 One of the design decisions in Flask was that simple tasks should be simple;10 they should not take a lot of code and yet they should not limit you. Because11-of that, Flask has a few design choices that some people might find surprising or12-unorthodox. For example, Flask uses thread-local objects internally so that you13-don’t have to pass objects around from function to function within a request in14-order to stay threadsafe. This approach is convenient, but requires a valid11+of that, Flask has a few design choices that some people might find12+surprising or unorthodox. For example, Flask uses thread-local objects13+internally so that you don’t have to pass objects around from14+function to function within a request in order to stay threadsafe.15+This approach is convenient, but requires a valid16 request context for dependency injection or when attempting to reuse code which17 uses a value pegged to the request. The Flask project is honest about18 thread-locals, does not hide them, and calls out in the code and documentation19 where they are used.29 unmodified linesmodified:docs/becomingbig.rst+2 added-1 removed
33 unmodified lines34 35 The :class:`~flask.Flask` class has many methods designed for subclassing. You36 can quickly add or customize behavior by subclassing :class:`~flask.Flask` (see37 the linked method docs) and using that subclass wherever you instantiate an38-application class. This works well with :ref:`app-factories`. See :doc:`/patterns/subclassing` for an example.38+application class. This works well with :ref:`app-factories`.39+See :doc:`/patterns/subclassing` for an example.40 41 Wrap with middleware.42 ---------------------43 59 unmodified linesmodified:docs/blueprints.rst+8 added-7 removed
256 unmodified lines257 return render_template('pages/404.html')258 259 Most errorhandlers will simply work as expected; however, there is a caveat260 concerning handlers for 404 and 405 exceptions. These errorhandlers are only261-invoked from an appropriate ``raise`` statement or a call to ``abort`` in another262-of the blueprint's view functions; they are not invoked by, e.g., an invalid URL263-access. This is because the blueprint does not "own" a certain URL space, so264-the application instance has no way of knowing which blueprint errorhandler it265-should run if given an invalid URL. If you would like to execute different266-handling strategies for these errors based on URL prefixes, they may be defined267-at the application level using the ``request`` proxy object::261+invoked from an appropriate ``raise`` statement or a call to ``abort``262+in another of the blueprint's view functions; they are not invoked by,263+e.g., an invalid URL access. This is because the blueprint does not264+"own" a certain URL space, so the application instance has no way of265+knowing which blueprint errorhandler it should run if given an invalid URL.266+If you would like to execute different handling strategies for these errors267+based on URL prefixes, they may be defined at the application level using268+the ``request`` proxy object::269 270 @app.errorhandler(404)271 @app.errorhandler(405)272 def _handle_api_error(ex):6 unmodified linesmodified:docs/cli.rst+3 added-3 removed
191 unmodified lines192 environment variables. The variables use the pattern193 ``FLASK_COMMAND_OPTION``. For example, to set the port for the run194 command, instead of ``flask run --port 8000``:195 196-.. code-block:: none196+.. code-block:: bash197 198 $ export FLASK_RUN_PORT=8000199 $ flask run200 * Running on http://127.0.0.1:8000/7 unmodified lines208 209 The ``flask`` command will show a message if it detects dotenv files but210 python-dotenv is not installed.211 212-.. code-block:: none212+.. code-block:: bash213 214 $ flask run215 * Tip: There are .env files present. Do "pip install python-dotenv" to use them.216 3 unmodified lines220 a project runner that loads them already. Keep in mind that the221 environment variables must be set before the app loads or it won't222 configure as expected.223 224-.. code-block:: none224+.. code-block:: bash225 226 $ export FLASK_SKIP_DOTENV=1227 $ flask run228 240 unmodified linesmodified:docs/errorhandling.rst+11 added-7 removed
48 unmodified lines49 And then add this to your Flask app::50 51 import sentry_sdk52 from sentry_sdk.integrations.flask import FlaskIntegration53- 53+54 sentry_sdk.init('YOUR_DSN_HERE',integrations=[FlaskIntegration()])55 56 The `YOUR_DSN_HERE` value needs to be replaced with the DSN value you get57 from your Sentry installation.58 59-After installation, failures leading to an Internal Server Error are automatically reported to 60-Sentry and from there you can receive error notifications.59+After installation, failures leading to an Internal Server Error60+are automatically reported to Sentry and from there you can61+receive error notifications.62 63 Follow-up reads:64 65 * Sentry also supports catching errors from your worker queue (RQ, Celery) in a60 unmodified lines126 registered, :class:`~werkzeug.exceptions.HTTPException` subclasses show a127 generic message about their code, while other exceptions are converted to a128 generic 500 Internal Server Error.129 129-For example, if an instance of :exc:`ConnectionRefusedError` is raised, and a handler130-is registered for :exc:`ConnectionError` and :exc:`ConnectionRefusedError`,130+For example, if an instance of :exc:`ConnectionRefusedError` is raised,131+and a handler is registered for :exc:`ConnectionError` and132+:exc:`ConnectionRefusedError`,133 the more specific :exc:`ConnectionRefusedError` handler is called with the134 exception instance to generate the response.135 136 Handlers registered on the blueprint take precedence over those registered47 unmodified lines184 options in order to use your favorite debugger:185 186 * ``debug`` - whether to enable debug mode and catch exceptions187 * ``use_debugger`` - whether to use the internal Flask debugger186-* ``use_reloader`` - whether to reload and fork the process if modules were changed188+* ``use_reloader`` - whether to reload and fork the process if modules189+ were changed190 191 ``debug`` must be True (i.e., exceptions must be caught) in order for the other192 two options to have any value.193 6 unmodified lines200 FLASK:201 DEBUG: True202 DEBUG_WITH_APTANA: True203 201-Then in your application's entry-point (main.py), you could have something like::204+Then in your application's entry-point (main.py),205+you could have something like::206 207 if __name__ == "__main__":208 # To allow aptana to receive errors, set use_debugger=False209 app = create_app(config="config.yaml")4 unmodified linesmodified:docs/extensiondev.rst+4 added-4 removed
195 unmodified lines196 2. The ``init_app`` method exists so that the ``SQLite3`` object can be197 instantiated without requiring an app object. This method supports the198 factory pattern for creating applications. The ``init_app`` will set the199 configuration for the database, defaulting to an in memory database if200- no configuration is supplied. In addition, the ``init_app`` method attaches201- the ``teardown`` handler.200+ no configuration is supplied. In addition, the ``init_app`` method201+ attaches the ``teardown`` handler.202 3. Next, we define a ``connect`` method that opens a database connection.203 4. Finally, we add a ``connection`` property that on first access opens204 the database connection and stores it on the context. This is also205 the recommended way to handling resources: fetch resources lazily the105 unmodified lines311 2. It must ship a testing suite that can either be invoked with ``make test``312 or ``python setup.py test``. For test suites invoked with ``make313 test`` the extension has to ensure that all dependencies for the test314 are installed automatically. If tests are invoked with ``python setup.py315- test``, test dependencies can be specified in the :file:`setup.py` file. The316- test suite also has to be part of the distribution.315+ test``, test dependencies can be specified in the :file:`setup.py` file.316+ The test suite also has to be part of the distribution.317 3. APIs of approved extensions will be checked for the following318 characteristics:319 320 - an approved extension has to support multiple applications25 unmodified linesmodified:docs/foreword.rst+5 added-4 removed
26 unmodified lines27 Configuration and Conventions28 -----------------------------29 30 Flask has many configuration values, with sensible defaults, and a few31-conventions when getting started. By convention, templates and static files are32-stored in subdirectories within the application's Python source tree, with the33-names :file:`templates` and :file:`static` respectively. While this can be changed, you34-usually don't have to, especially when getting started.31+conventions when getting started. By convention, templates and static32+files are stored in subdirectories within the application's Python33+source tree, with the names :file:`templates` and :file:`static`34+respectively. While this can be changed, you usually don't have to,35+especially when getting started.36 37 Growing with Flask38 ------------------39 19 unmodified linesmodified:docs/htmlfaq.rst+2 added-2 removed
14 unmodified lines15 However, barely any websites on the Internet are actual XHTML (which is16 HTML processed using XML rules). There are a couple of major reasons17 why this is the case. One of them is Internet Explorer's lack of proper18 XHTML support. The XHTML spec states that XHTML must be served with the MIME19-type :mimetype:`application/xhtml+xml`, but Internet Explorer refuses to read files20-with that MIME type.19+type :mimetype:`application/xhtml+xml`, but Internet Explorer refuses20+to read files with that MIME type.21 While it is relatively easy to configure Web servers to serve XHTML properly,22 few people do. This is likely because properly using XHTML can be quite23 painful.24 183 unmodified linesmodified:docs/quickstart.rst+20 added-18 removed
91 unmodified lines92 93 What to do if the Server does not Start94 ---------------------------------------95 96-In case the :command:`python -m flask` fails or :command:`flask` does not exist,97-there are multiple reasons this might be the case. First of all you need98-to look at the error message.96+In case the :command:`python -m flask` fails or :command:`flask`97+does not exist, there are multiple reasons this might be the case.98+First of all you need to look at the error message.99 100 Old Version of Flask101 ````````````````````102 456 unmodified lines559 filesystem. You can access those files by looking at the560 :attr:`~flask.request.files` attribute on the request object. Each561 uploaded file is stored in that dictionary. It behaves just like a562 standard Python :class:`file` object, but it also has a563-:meth:`~werkzeug.datastructures.FileStorage.save` method that allows you to store that564-file on the filesystem of the server. Here is a simple example showing how565-that works::563+:meth:`~werkzeug.datastructures.FileStorage.save` method that564+allows you to store that file on the filesystem of the server.565+Here is a simple example showing how that works::566 567 from flask import request568 569 @app.route('/upload', methods=['GET', 'POST'])4 unmodified lines574 ...575 576 If you want to know how the file was named on the client before it was577 uploaded to your application, you can access the578-:attr:`~werkzeug.datastructures.FileStorage.filename` attribute. However please keep in579-mind that this value can be forged so never ever trust that value. If you580-want to use the filename of the client to store the file on the server,581-pass it through the :func:`~werkzeug.utils.secure_filename` function that578+:attr:`~werkzeug.datastructures.FileStorage.filename` attribute.579+However please keep in mind that this value can be forged580+so never ever trust that value. If you want to use the filename581+of the client to store the file on the server, pass it through the582+:func:`~werkzeug.utils.secure_filename` function that583 Werkzeug provides for you::584 585 from flask import request586 from werkzeug.utils import secure_filename94 unmodified lines681 682 The return value from a view function is automatically converted into a683 response object for you. If the return value is a string it's converted684 into a response object with the string as response body, a ``200 OK``684-status code and a :mimetype:`text/html` mimetype. The logic that Flask applies to685-converting return values into response objects is as follows:685+status code and a :mimetype:`text/html` mimetype.686+The logic that Flask applies to converting return values into687+response objects is as follows:688 689 1. If a response object of the correct type is returned it's directly690 returned from the view.691 2. If it's a string, a response object is created with that data and the115 unmodified lines807 808 .. versionadded:: 0.3809 810 Sometimes you might be in a situation where you deal with data that809-should be correct, but actually is not. For example you may have some client-side810-code that sends an HTTP request to the server but it's obviously811-malformed. This might be caused by a user tampering with the data, or the812-client code failing. Most of the time it's okay to reply with ``400 Bad813-Request`` in that situation, but sometimes that won't do and the code has814-to continue working.811+should be correct, but actually is not. For example you may have812+some client-side code that sends an HTTP request to the server813+but it's obviously malformed. This might be caused by a user tampering814+with the data, or the client code failing. Most of the time it's okay815+to reply with ``400 Bad Request`` in that situation, but sometimes816+that won't do and the code has to continue working.817 818 You may still want to log that something fishy happened. This is where819 loggers come in handy. As of Flask 0.3 a logger is preconfigured for you820 to use.38 unmodified linesmodified:docs/testing.rst+15 added-12 removed
71 unmodified lines72 this does is disable error catching during request handling, so that73 you get better error reports when performing test requests against the74 application.75 76-Because SQLite3 is filesystem-based, we can easily use the :mod:`tempfile` module77-to create a temporary database and initialize it. The78-:func:`~tempfile.mkstemp` function does two things for us: it returns a76+Because SQLite3 is filesystem-based, we can easily use the77+:mod:`tempfile` module to create a temporary database and initialize it.78+The :func:`~tempfile.mkstemp` function does two things for us: it returns a79 low-level file handle and a random file name, the latter we use as80 database name. We just have to keep the `db_fd` around so that we can use81 the :func:`os.close` function to close the file.82 9 unmodified lines92 collected 0 items93 94 =========== no tests ran in 0.07 seconds ============95 96-Even though it did not run any actual tests, we already know that our ``flaskr``97-application is syntactically valid, otherwise the import would have died98-with an exception.96+Even though it did not run any actual tests, we already know that our97+``flaskr`` application is syntactically valid, otherwise the import98+would have died with an exception.99 100 .. _pytest fixture:101 https://docs.pytest.org/en/latest/fixture.html102 13 unmodified lines116 117 Notice that our test functions begin with the word `test`; this allows118 `pytest`_ to automatically identify the function as a test to run.119 120-By using ``client.get`` we can send an HTTP ``GET`` request to the application with121-the given path. The return value will be a :class:`~flask.Flask.response_class` object.122-We can now use the :attr:`~werkzeug.wrappers.BaseResponse.data` attribute to inspect123-the return value (as string) from the application. In this case, we ensure that124-``'No entries here so far'`` is part of the output.120+By using ``client.get`` we can send an HTTP ``GET`` request to the121+application with the given path. The return value will be a122+:class:`~flask.Flask.response_class` object. We can now use the123+:attr:`~werkzeug.wrappers.BaseResponse.data` attribute to inspect124+the return value (as string) from the application.125+In this case, we ensure that ``'No entries here so far'``126+is part of the output.127 128 Run it again and you should see one passing test::129 130 $ pytest -v203 unmodified lines334 assert request.args['tequila'] == '42'335 336 If you were to use just the :meth:`~flask.Flask.test_client` without337 the ``with`` block, the ``assert`` would fail with an error because `request`336-is no longer available (because you are trying to use it outside of the actual request).338+is no longer available (because you are trying to use it339+outside of the actual request).340 341 342 Accessing and Modifying Sessions343 --------------------------------116 unmodified linesmodified:docs/upgrading.rst+3 added-3 removed
66 unmodified lines67 to the release we decided to push out a 0.11 release first with some68 changes removed to make the transition easier. If you have been tracking69 the master branch which was 1.0 you might see some unexpected changes.70 71-In case you did track the master branch you will notice that :command:`flask --app`72-is removed now. You need to use the environment variable to specify an73-application.71+In case you did track the master branch you will notice that72+:command:`flask --app` is removed now.73+You need to use the environment variable to specify an application.74 75 Debugging76 `````````77 395 unmodified lines