minor revision of documentation.
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by bagratte · committed by Markus Unterwaditzer · parent e0a8fd3 · Browse files · 13 files·+32 added−37 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
13 files+32 added−37 removed
- other:+32 added−37 removed
Provenance
- Commit
9a80fe6- Tree
c173216- Author
bagratte <bagratte@live.com>- Committer
Markus Unterwaditzer <markus@unterwaditzer.net>- Parent
e0a8fd3
13 files changed+32 added−37 removed
modified:docs/deploying/mod_wsgi.rst+1 added-1 removed
141 unmodified lines142 143 If your application does not run, follow this guide to troubleshoot:144 145 **Problem:** application does not run, errorlog shows SystemExit ignored146- You have a ``app.run()`` call in your application file that is not146+ You have an ``app.run()`` call in your application file that is not147 guarded by an ``if __name__ == '__main__':`` condition. Either148 remove that :meth:`~flask.Flask.run` call from the file and move it149 into a separate :file:`run.py` file or put it into such an if block.150 67 unmodified linesmodified:docs/deploying/uwsgi.rst-6 removed
29 unmodified lines30 .. sourcecode:: text31 32 $ uwsgi -s /tmp/uwsgi.sock --manage-script-name --mount /yourapplication=myapp:app33 34-Or, if you prefer:35-36-.. sourcecode:: text37-38- $ uwsgi -s /tmp/uwsgi.sock --manage-script-name --mount /yourapplication=myapp:app39-34 The ``--manage-script-name`` will move the handling of ``SCRIPT_NAME`` to35 uwsgi, since its smarter about that. It is used together with the ``--mount``36 directive which will make requests to ``/yourapplication`` be directed to37 ``myapp:app``, where ``myapp`` refers to the name of the file of your flask33 unmodified linesmodified:docs/patterns/appdispatch.rst+7 added-7 removed
2 unmodified lines3 Application Dispatching4 =======================5 6 Application dispatching is the process of combining multiple Flask7-applications on the WSGI level. You can not only combine Flask8-applications into something larger but any WSGI application. This would9-even allow you to run a Django and a Flask application in the same10-interpreter side by side if you want. The usefulness of this depends on11-how the applications work internally.7+applications on the WSGI level. You can combine not only Flask8+applications but any WSGI application. This would allow you to run a9+Django and a Flask application in the same interpreter side by side if10+you want. The usefulness of this depends on how the applications work11+internally.12 13 The fundamental difference from the :ref:`module approach14 <larger-applications>` is that in this case you are running the same or15 different Flask applications that are entirely isolated from each other.14 unmodified lines30 Note that :func:`run_simple <werkzeug.serving.run_simple>` is not intended for31 use in production. Use a :ref:`full-blown WSGI server <deployment>`.32 33 In order to use the interactive debugger, debugging must be enabled both on34-the application and the simple server, here is the "hello world" example with34+the application and the simple server. Here is the "hello world" example with35 debugging and :func:`run_simple <werkzeug.serving.run_simple>`::36 37 from flask import Flask38 from werkzeug.serving import run_simple16 unmodified lines55 If you have entirely separated applications and you want them to work next56 to each other in the same Python interpreter process you can take57 advantage of the :class:`werkzeug.wsgi.DispatcherMiddleware`. The idea58 here is that each Flask application is a valid WSGI application and they59-are combined by the dispatcher middleware into a larger one that59+are combined by the dispatcher middleware into a larger one that is60 dispatched based on prefix.61 62 For example you could have your main application run on ``/`` and your63 backend interface on ``/backend``::125 unmodified linesmodified:docs/patterns/deferredcallbacks.rst+3 added-3 removed
54 unmodified lines55 56 A Practical Example57 -------------------58 59-Now we can easily at any point in time register a function to be called at60-the end of this particular request. For example you can remember the61-current language of the user in a cookie in the before-request function::59+At any time during a request, we can register a function to be called at the60+end of the request. For example you can remember the current language of the61+user in a cookie in the before-request function::62 63 from flask import request64 65 @app.before_request8 unmodified linesmodified:docs/tutorial/dbinit.rst+2 added-2 removed
36 unmodified lines37 print 'Initialized the database.'38 39 The ``app.cli.command()`` decorator registers a new command with the40 :command:`flask` script. When the command executes, Flask will automatically41-create a application context for us bound to the right application.41+create an application context for us bound to the right application.42 Within the function, we can then access :attr:`flask.g` and other things as43 we would expect. When the script ends, the application context tears down44 and the database connection is released.45 46-We want to keep an actual functions around that initializes the database,46+We want to keep an actual function around that initializes the database,47 though, so that we can easily create databases in unit tests later on. (For48 more information see :ref:`testing`.)49 50 The :func:`~flask.Flask.open_resource` method of the application object22 unmodified linesmodified:docs/tutorial/views.rst+3 added-3 removed
10 unmodified lines11 12 This view shows all the entries stored in the database. It listens on the13 root of the application and will select title and text from the database.14 The one with the highest id (the newest entry) will be on top. The rows15-returned from the cursor look a bit like tuples because we are using15+returned from the cursor look a bit like dictionaries because we are using16 the :class:`sqlite3.Row` row factory.17 18-The view function will pass the entries as dictionaries to the19-:file:`show_entries.html` template and return the rendered one::18+The view function will pass the entries to the :file:`show_entries.html`19+template and return the rendered one::20 21 @app.route('/')22 def show_entries():23 db = get_db()75 unmodified linesmodified:docs/appcontext.rst+2 added-2 removed
24 unmodified lines25 - any code can get hold of these objects at any time.26 27 There is a third state which is sitting in between a little bit.28 Sometimes you are dealing with an application in a way that is similar to29-how you interact with applications during request handling just that there30-is no request active. Consider for instance that you're sitting in an29+how you interact with applications during request handling; just that there30+is no request active. Consider, for instance, that you're sitting in an31 interactive Python shell and interacting with the application, or a32 command line application.33 34 The application context is what powers the :data:`~flask.current_app`99 unmodified linesmodified:docs/config.rst+1 added-1 removed
328 unmodified lines329 there are alternative ways as well. For example you could use imports or330 subclassing.331 332 What is very popular in the Django world is to make the import explicit in333-the config file by adding an ``from yourapplication.default_settings333+the config file by adding ``from yourapplication.default_settings334 import *`` to the top of the file and then overriding the changes by hand.335 You could also inspect an environment variable like336 ``YOURAPPLICATION_MODE`` and set that to `production`, `development` etc337 and import different hardcoded files based on that.126 unmodified linesmodified:docs/errorhandling.rst+6 added-5 removed
57 unmodified lines58 :exc:`~werkzeug.exceptions.BadRequest` from the example and their HTTP codes59 are interchangeable when handed to the registration methods or decorator60 (``BadRequest.code == 400``).61 62-You are however not limited to a :exc:`~werkzeug.exceptions.HTTPException`63-or its code but can register a handler for every exception class you like.62+You are however not limited to :exc:`~werkzeug.exceptions.HTTPException`63+or HTTP status codes but can register a handler for every exception class you64+like.65 66 .. versionchanged:: 1.067 67- Errorhandlers are now prioritized by specifity instead of the order they're68- registered in.68+ Errorhandlers are now prioritized by specificity of the exception classes69+ they are registered for instead of the order they are registered in.70 71 Handling72 ````````73 74 Once an exception instance is raised, its class hierarchy is traversed,75 and searched for in the exception classes for which handlers are registered.76 The most specific handler is selected.77 77-E.g. if a instance of :exc:`ConnectionRefusedError` is raised, and a handler78+E.g. if an instance of :exc:`ConnectionRefusedError` is raised, and a handler79 is registered for :exc:`ConnectionError` and :exc:`ConnectionRefusedError`,80 the more specific :exc:`ConnectionRefusedError` handler is called on the81 exception instance, and its response is shown to the user.82 271 unmodified linesmodified:docs/htmlfaq.rst+1 added-1 removed
28 unmodified lines29 the (X)HTML generation on the web is based on non-XML template engines30 (such as Jinja, the one used in Flask) which do not protect you from31 accidentally creating invalid XHTML. There are XML based template engines,32 such as Kid and the popular Genshi, but they often come with a larger33-runtime overhead and, are not as straightforward to use because they have33+runtime overhead and are not as straightforward to use because they have34 to obey XML rules.35 36 The majority of users, however, assumed they were properly using XHTML.37 They wrote an XHTML doctype at the top of the document and self-closed all170 unmodified linesmodified:docs/quickstart.rst+1 added-1 removed
319 unmodified lines320 You have no idea what an HTTP method is? Worry not, here is a quick321 introduction to HTTP methods and why they matter:322 323 The HTTP method (also often called "the verb") tells the server what the324-clients wants to *do* with the requested page. The following methods are324+client wants to *do* with the requested page. The following methods are325 very common:326 327 ``GET``328 The browser tells the server to just *get* the information stored on566 unmodified linesmodified:docs/signals.rst+3 added-3 removed
17 unmodified lines18 more. Also keep in mind that signals are intended to notify subscribers19 and should not encourage subscribers to modify data. You will notice that20 there are signals that appear to do the same thing like some of the21 builtin decorators do (eg: :data:`~flask.request_started` is very similar22-to :meth:`~flask.Flask.before_request`). There are however difference in23-how they work. The core :meth:`~flask.Flask.before_request` handler for24-example is executed in a specific order and is able to abort the request22+to :meth:`~flask.Flask.before_request`). However, there are differences in23+how they work. The core :meth:`~flask.Flask.before_request` handler, for24+example, is executed in a specific order and is able to abort the request25 early by returning a response. In contrast all signal handlers are26 executed in undefined order and do not modify any data.27 28 The big advantage of signals over handlers is that you can safely162 unmodified linesmodified:docs/testing.rst+2 added-2 removed
221 unmodified lines222 there does not seem to be a good way to do that, consider switching to223 application factories (see :ref:`app-factories`).224 225 Note however that if you are using a test request context, the226-:meth:`~flask.Flask.before_request` functions are not automatically called227-same for :meth:`~flask.Flask.after_request` functions. However226+:meth:`~flask.Flask.before_request` and :meth:`~flask.Flask.after_request`227+functions are not called automatically. However228 :meth:`~flask.Flask.teardown_request` functions are indeed executed when229 the test request context leaves the ``with`` block. If you do want the230 :meth:`~flask.Flask.before_request` functions to be called as well, you231 need to call :meth:`~flask.Flask.preprocess_request` yourself::124 unmodified lines