Skip to content
Myr

More typo fixes.

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

authored by Georg Brandl · committed by Armin Ronacher · parent 63caf6e · Browse files · 9 files+24 added−24 removed
This commit

State

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

Diff stats

9 files+24 added−24 removed

  • other:+24 added−24 removed

9 files+24 added−24 removed

modified:docs/deploying/mod_wsgi.rst+4 added-4 removed
17 unmodified lines
1819If you don't have `mod_wsgi` installed yet you have to either install it using20a package manager or compile it yourself.2122The mod_wsgi `installation instructions`_ cover source installations on UNIX 22The mod_wsgi `installation instructions`_ cover source installations on UNIX23systems.2425If you are using ubuntu / debian you can apt-get it and activate it as follows:25If you are using Ubuntu/Debian you can apt-get it and activate it as follows:2627.. sourcecode:: text2829 # apt-get install libapache2-mod-wsgi
65 unmodified lines
95--------------9697If your application does not run, follow this guide to troubleshoot:9899**Problem:** Application does not run, errorlog shows SystemExit ignored99**Problem:** application does not run, errorlog shows SystemExit ignored100 You have a ``app.run()`` call in your application file that is not101 guarded by an ``if __name__ == '__main__':`` condition. Either remove102 that :meth:`~flask.Flask.run` call from the file and move it into a103 separate `run.py` file or put it into such an if block.
25 unmodified lines
129 site-packages folder. Please be aware that this does not work,130 instead you either have to put the folder into the pythonpath the file131 is stored in, or convert your application into a package.132133 The reason for this is that for non-installed Packages, the module133 The reason for this is that for non-installed packages, the module134 filename is used to locate the resources and for symlinks the wrong135 filename is picked up.
modified:docs/tutorial/css.rst+1 added-1 removed
12 unmodified lines
13 a, h1, h2 { color: #377BA8; }14 h1, h2 { font-family: 'Georgia', serif; margin: 0; }15 h1 { border-bottom: 2px solid #eee; }16 h2 { font-size: 1.2em; }17 1718 .page { margin: 2em auto; width: 35em; border: 5px solid #ccc;19 padding: 0.8em; background: white; }20 .entries { list-style: none; margin: 0; padding: 0; }21 .entries li { margin: 0.8em 1.2em; }
10 unmodified lines
modified:docs/tutorial/dbinit.rst+1 added-1 removed
29 unmodified lines
3031Next we can create a function called `init_db` that initializes the32database. For this we can use the `connect_db` function we defined33earlier. Just add that function below the `connect_db` function::34 3435 def init_db():36 with closing(connect_db()) as db:37 with app.open_resource('schema.sql') as f:38 db.cursor().executescript(f.read())
29 unmodified lines
modified:docs/tutorial/testing.rst+1 added-1 removed
1.. _tutorial-testing:23Bonus: Testing the Application4===============================4==============================56Now that you have finished the application and everything works as7expected, it's probably not a good idea to add automated tests to simplify8modifications in the future. The application above is used as a basic
2 unmodified lines
modified:docs/api.rst+1 added-1 removed
67 unmodified lines
68 If the incoming form data was not encoded with a known mimetype69 the data is stored unmodified in this stream for consumption. Most70 of the time it is a better idea to use :attr:`data` which will give71 you that data as a string. The stream only returns the data once.72 7273 .. attribute:: data7475 Contains the incoming request data as string in case it came with76 a mimetype Flask does not handle.
216 unmodified lines
modified:docs/design.rst+3 added-3 removed
88 unmodified lines
8990But that's about where similarities end. Jinja2 for example has an91extensive filter system, a certain way to do template inheritance, support92for reusable blocks (macros) that can be used from inside templates and93also from Python code, uses unicode for all operations, supports93also from Python code, uses Unicode for all operations, supports94iterative template rendering, configurable syntax and more. On the other95hand an engine like Genshi is based on XML stream evaluation, template96inheritance by taking the availability of XPath into account and more.97Mako on the other hand treats templates similar to Python modules.9899When it comes to connecting a template engine with an application or 99When it comes to connecting a template engine with an application or100framework there is more than just rendering templates. For instance,101Flask uses Jinja2's extensive autoescaping support. Also it provides 101Flask uses Jinja2's extensive autoescaping support. Also it provides102ways to access macros from Jinja2 templates.103104A template abstraction layer that would not take the unique features of105the template engines away is a science on its own and a too large
42 unmodified lines
modified:docs/installation.rst+1 added-1 removed
27 unmodified lines
28you have shell access. So first: what does virtualenv do? If you are29like me and you like Python, chances are you want to use it for another30project as well. Now the more projects you have, the more likely it is31that you will be working with different versions of Python itself or at32least an individual library. Because let's face it: quite often libraries 32least an individual library. Because let's face it: quite often libraries33break backwards compatibility and it's unlikely that your application will34not have any dependencies, that just won't happen. So virtualenv to the35rescue!36
139 unmodified lines
modified:docs/quickstart.rst+9 added-9 removed
207 unmodified lines
208>>> from flask import Flask, url_for209>>> app = Flask(__name__)210>>> @app.route('/')211... def index(): pass212... 212...213>>> @app.route('/login')214... def login(): pass215... 215...216>>> @app.route('/user/<username>')217... def profile(username): pass218... 218...219>>> with app.test_request_context():220... print url_for('index')221... print url_for('login')222... print url_for('login', next='/')223... print url_for('profile', username='John Doe')224... 224...225/226/login227/login?next=/228/user/John%20Doe
8 unmodified lines
2372381. reversing is often more descriptive than hardcoding the URLs. Also and239 more importantly you can change URLs in one go without having to change240 the URLs all over the place.2412. URL building will handle escaping of special characters and unicode2412. URL building will handle escaping of special characters and Unicode242 data transparently for you, you don't have to deal with that.2433. If your application is placed outside the URL root (so say in244 ``/myapplication`` instead of ``/``), :func:`~flask.url_for` will245 handle that properly for you.
108 unmodified lines
354application is a module, that folder is next to that module, if it's a355package it's actually inside your package:356357**Case 1**: a module::358 358359 /application.py360 /templates361 /hello.html362
299 unmodified lines
662.. admonition:: How to generate good Secret Keys663664 The problem with random is that it's hard to judge what random is. And665 a secret key should be as random as possible. Your operating system666 has ways to generate pretty random stuff based on a cryptographical666 has ways to generate pretty random stuff based on a cryptographic667 random generator which can be used to get such a key:668669 >>> import os670 >>> os.urandom(24)
35 unmodified lines
706707Here are some example log calls::708709 app.logger.debug('A value for debugging')710 app.logger.warning('A warning ocurred (%d apples)', 42)711 app.logger.error('An error occoured')710 app.logger.warning('A warning occurred (%d apples)', 42)711 app.logger.error('An error occurred')712713The attached :attr:`~flask.Flask.logger` is a standard logging714:class:`~logging.Logger`, so head over to the official stdlib715documentation for more information.
modified:docs/testing.rst+3 added-3 removed
68 unmodified lines
69low-level file handle and a random file name, the latter we use as70database name. We just have to keep the `db_fd` around so that we can use71the :func:`os.close` function to close the file.7273If we now run that testsuite, we should see the following output::73If we now run that test suite, we should see the following output::7475 $ python flaskr_tests.py7677 ----------------------------------------------------------------------
102 unmodified lines
180which is the intended behavior.181182Running that should now give us three passing tests::183184 $ python flaskr_tests.py 184 $ python flaskr_tests.py185 ...186 ----------------------------------------------------------------------187 Ran 3 tests in 0.332s188 188189 OK190191For more complex tests with headers and status codes, check out the192`MiniTwit Example`_ from the sources. That one contains a larger test
28 unmodified lines