Skip to content
Myr

Fix some typos in the docs

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by jgraeme · committed by Armin Ronacher · parent d09aa37 · Browse files · 8 files+16 added−16 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

8 files+16 added−16 removed

  • other:+16 added−16 removed

8 files+16 added−16 removed

modified:docs/patterns/errorpages.rst+1 added-1 removed
3 unmodified lines
4Flask comes with a handy :func:`~flask.abort` function that aborts a5request with an HTTP error code early. It will also provide a plain black6and white error page for you with a basic description, but nothing fancy.78Depening on the error code it is less or more likely for the user to8Depending on the error code it is less or more likely for the user to9actually see such an error.1011Common Error Codes12------------------
65 unmodified lines
modified:docs/patterns/jquery.rst+4 added-4 removed
51 unmodified lines
52is quite simple: it's on localhost port something and directly on the root53of that server. But what if you later decide to move your application to54a different location? For example to ``http://example.com/myapp``? On55the server side this never was a problem because we were using the handy56:func:`~flask.url_for` function that did could answer that question for57us, but if we are using jQuery we should better not hardcode the path to56:func:`~flask.url_for` function that could answer that question for57us, but if we are using jQuery we should not hardcode the path to58the application but make that dynamic, so how can we do that?5960A simple method would be to add a script tag to our page that sets a61global variable to the prefix to the root of the application. Something
55 unmodified lines
117118The HTML119--------120121You index.html template either has to extend a `layout.html` template with121Your index.html template either has to extend a `layout.html` template with122jQuery loaded and the `$SCRIPT_ROOT` variable set, or do that on the top.123Here the HTML code needed for our little application (`index.html`).123Here's the HTML code needed for our little application (`index.html`).124Notice that we also drop the script directly into the HTML here. It is125usually a better idea to have that in a separate script file:126127.. sourcecode:: html
40 unmodified lines
modified:docs/patterns/lazyloading.rst+1 added-1 removed
72 unmodified lines
73 def __call__(self, *args, **kwargs):74 return self.view(*args, **kwargs)7576What's important here is is that `__module__` and `__name__` are properly77set. This is used by Flask internally to figure out how to do name the77set. This is used by Flask internally to figure out how to name the78URL rules in case you don't provide a name for the rule yourself.7980Then you can define your central place to combine the views like this::81
23 unmodified lines
modified:docs/patterns/wtforms.rst+2 added-2 removed
75 unmodified lines
76how easy this is. WTForms does half the form generation for us already.77To make it even nicer, we can write a macro that renders a field with78label and a list of errors if there are any.7980Here an example `_formhelpers.html` template with such a macro:80Here's an example `_formhelpers.html` template with such a macro:8182.. sourcecode:: html+jinja8384 {% macro render_field(field) %}
7 unmodified lines
92 </dd>93 {% endmacro %}9495This macro accepts a couple of keyword arguments that are forwarded to96WTForm's field function that renders the field for us. They keyword96WTForm's field function that renders the field for us. The keyword97arguments will be inserted as HTML attributes. So for example you can98call ``render_field(form.username, class='username')`` to add a class to99the input element. Note that WTForms returns standard Python unicode100strings, so we have to tell Jinja2 that this data is already HTML escaped
24 unmodified lines
modified:docs/extensiondev.rst+4 added-4 removed
65 unmodified lines
66 sqlite3.py67 setup.py68 LICENSE6970Here the contents of the most important files:70Here's the contents of the most important files:7172flaskext/__init__.py73````````````````````74
95 unmodified lines
170171The Extension Code172------------------173174Here the contents of the `flaskext/sqlite3.py` for copy/paste::174Here's the contents of the `flaskext/sqlite3.py` for copy/paste::175176 from __future__ import absolute_import177 import sqlite3178 from flask import g
16 unmodified lines
195 def after_request(self, response):196 g.sqlite3_db.close()197 return response198199So here what the lines of code do:199So here's what the lines of code do:2002011. the ``__future__`` import is necessary to activate absolute imports.202 This is needed because otherwise we could not call our module203 `sqlite3.py` and import the top-level `sqlite3` module which actually
32 unmodified lines
236237Initialization Functions238------------------------239240Here how the module would look like with initialization functions::240Here's what the module would look like with initialization functions::241242 from __future__ import absolute_import243 import sqlite3244 from flask import g
83 unmodified lines
modified:docs/quickstart.rst+1 added-1 removed
229 unmodified lines
230/login?next=/231/user/John%20Doe232233(This also uses the :meth:`~flask.Flask.test_request_context` method234explained below. It basically tells flask to think we are handling a234explained below. It basically tells Flask to think we are handling a235request even though we are not, we are in an interactive Python shell.236Have a look at the explanation below. :ref:`context-locals`).237238Why would you want to build URLs instead of hardcoding them in your
507 unmodified lines
modified:docs/security.rst+2 added-2 removed
70 unmodified lines
71do stupid things without them knowing.7273Say you have a specific URL that, when you sent `POST` requests to will74delete a user's profile (say `http://example.com/user/delete`). If an75attacker now creates a page that sents a post request to that page with75attacker now creates a page that sends a post request to that page with76some JavaScript he just has to trick some users to that page and their77profiles will end up being deleted.7879Imagine you would run Facebook with millions of concurrent users and
82 unmodified lines
162163Because it is a syntax error in JavaScript to have an object literal164(``{...}``) toplevel an attacker could not just do a request to an165external URL with the script tag to load up the data. So what Flask does166is only allowing objects as toplevel elements when using166is to only allow objects as toplevel elements when using167:func:`~flask.jsonify`. Make sure to do the same when using an ordinary168JSON generate function.
modified:docs/upgrading.rst+1 added-1 removed
1Upgrading to Newer Releases2===========================34Flask itself is changing like any software is changing over time. Most of5the changes are the nice kind, the kind where you don't have th change5the changes are the nice kind, the kind where you don't have to change6anything in your code to profit from a new release.78However every once in a while there are changes that do require some9changes in your code or there are changes that make it possible for you to
103 unmodified lines