Skip to content
Myr

Less annoying gender neutral forms

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

authored by Armin Ronacher · committed by Armin Ronacher · parent d3b0edb · Browse files · 8 files+12 added−12 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+12 added−12 removed

  • other:+12 added−12 removed

8 files+12 added−12 removed

modified:docs/patterns/errorpages.rst+2 added-2 removed
22 unmodified lines
2324*403 Forbidden*25 If you have some kind of access control on your website, you will have26 to send a 403 code for disallowed resources. So make sure the user27 is not lost when he or she tries to access a forbidden resource.27 is not lost when they try to access a forbidden resource.2829*410 Gone*30 Did you know that there the "404 Not Found" has a brother named "41031 Gone"? Few people actually implement that, but the idea is that32 resources that previously existed and got deleted answer with 41033 instead of 404. If you are not deleting documents permanently from34 the database but just mark them as deleted, do the user a favour and35 use the 410 code instead and display a message that what he or she was35 use the 410 code instead and display a message that what they were36 looking for was deleted for all eternity.3738*500 Internal Server Error*39 Usually happens on programming errors or if the server is overloaded.
38 unmodified lines
modified:docs/patterns/flashing.rst+1 added-1 removed
2 unmodified lines
3Message Flashing4================56Good applications and user interfaces are all about feedback. If the user7does not get enough feedback he or she will probably end up hating the7does not get enough feedback they will probably end up hating the8application. Flask provides a really simple way to give feedback to a9user with the flashing system. The flashing system basically makes it10possible to record a message at the end of a request and access it next11request and only next request. This is usually combined with a layout
108 unmodified lines
modified:docs/patterns/viewdecorators.rst+1 added-1 removed
6 unmodified lines
7functionality to one or more functions. The :meth:`~flask.Flask.route`8decorator is the one you probably used already. But there are use cases9for implementing your own decorator. For instance, imagine you have a10view that should only be used by people that are logged in to. If a user11goes to the site and is not logged in, he or she should be redirected to the11goes to the site and is not logged in, they should be redirected to the12login page. This is a good example of a use case where a decorator is an13excellent solution.1415Login Required Decorator
153 unmodified lines
modified:docs/tutorial/introduction.rst+1 added-1 removed
6 unmodified lines
7less web-2.0-ish name ;) Basically we want it to do the following things:891. let the user sign in and out with credentials specified in the10 configuration. Only one user is supported.112. when the user is logged in he or she can add new entries to the page112. when the user is logged in they can add new entries to the page12 consisting of a text-only title and some HTML for the text. This HTML13 is not sanitized because we trust the user here.143. the page shows all entries so far in reverse order (newest on top) and15 the user can add new ones from there if logged in.
18 unmodified lines
modified:docs/tutorial/views.rst+1 added-1 removed
27 unmodified lines
2829Add New Entry30-------------3132This view lets the user add new entries if he or she is logged in. This only32This view lets the user add new entries if they are logged in. This only33responds to `POST` requests, the actual form is shown on the34`show_entries` page. If everything worked out well we will35:func:`~flask.flash` an information message to the next request and36redirect back to the `show_entries` page::
62 unmodified lines
modified:docs/api.rst+1 added-1 removed
154 unmodified lines
155If you have the :attr:`Flask.secret_key` set you can use sessions in Flask156applications. A session basically makes it possible to remember157information from one request to another. The way Flask does this is by158using a signed cookie. So the user can look at the session contents, but159not modify it unless he or she knows the secret key, so make sure to set that159not modify it unless they know the secret key, so make sure to set that160to something complex and unguessable.161162To access the current session you can use the :class:`session` object:163
265 unmodified lines
modified:docs/quickstart.rst+4 added-4 removed
124 unmodified lines
125Modern web applications have beautiful URLs. This helps people remember126the URLs which is especially handy for applications that are used from127mobile devices with slower network connections. If the user can directly128go to the desired page without having to hit the index page it is more129likely he or she will like the page and come back next time.129likely they will like the page and come back next time.130131As you have seen above, the :meth:`~flask.Flask.route` decorator is used132to bind a function to a URL. Here are some basic examples::133
479 unmodified lines
613 abort(401)614 this_is_never_executed()615616This is a rather pointless example because a user will be redirected from617the index to a page he or she cannot access (401 means access denied) but it617the index to a page they cannot access (401 means access denied) but it618shows how that works.619620By default a black and white error page is shown for each error code. If621you want to customize the error page, you can use the
18 unmodified lines
640:class:`~flask.session` that allows you to store information specific to a641user from one request to the next. This is implemented on top of cookies642for you and signs the cookies cryptographically. What this means is that643the user could look at the contents of your cookie but not modify it,644unless he or she knows the secret key used for signing.644unless they know the secret key used for signing.645646In order to use sessions you have to set a secret key. Here is how647sessions work::648
47 unmodified lines
696Message Flashing697----------------698699Good applications and user interfaces are all about feedback. If the user700does not get enough feedback he or she will probably end up hating the700does not get enough feedback they will probably end up hating the701application. Flask provides a really simple way to give feedback to a702user with the flashing system. The flashing system basically makes it703possible to record a message at the end of a request and access it next704request and only next request. This is usually combined with a layout
45 unmodified lines
modified:docs/security.rst+1 added-1 removed
71 unmodified lines
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 sends a post request to that page with76some JavaScript he or she just has to trick some users to load that page and76some JavaScript they just has to trick some users to load that page and77their profiles will end up being deleted.7879Imagine you were to run Facebook with millions of concurrent users and80someone would send out links to images of little kittens. When users
95 unmodified lines