forked from orbit-oss/flask
Merge branch 'master' of github.com:mitsuhiko/flask
This commit is contained in:
commit
7fc0ddb57c
13 changed files with 24 additions and 16 deletions
5
CHANGES
5
CHANGES
|
|
@ -3,6 +3,11 @@ Flask Changelog
|
||||||
|
|
||||||
Here you can see the full list of changes between each Flask release.
|
Here you can see the full list of changes between each Flask release.
|
||||||
|
|
||||||
|
Version 0.10
|
||||||
|
------------
|
||||||
|
|
||||||
|
Release date to be decided.
|
||||||
|
|
||||||
Version 0.9
|
Version 0.9
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,7 @@ you can have more than one application in the same Python process.
|
||||||
|
|
||||||
So how does the code find the “right” application? In the past we
|
So how does the code find the “right” application? In the past we
|
||||||
recommended passing applications around explicitly, but that caused issues
|
recommended passing applications around explicitly, but that caused issues
|
||||||
with libraries that were not designed with that in mind for libraries for
|
with libraries that were not designed with that in mind.
|
||||||
which it was too inconvenient to make this work.
|
|
||||||
|
|
||||||
A common workaround for that problem was to use the
|
A common workaround for that problem was to use the
|
||||||
:data:`~flask.current_app` proxy later on, which was bound to the current
|
:data:`~flask.current_app` proxy later on, which was bound to the current
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ response objects. Dig deeper on the APIs you use, and look for the
|
||||||
customizations which are available out of the box in a Flask release. Look for
|
customizations which are available out of the box in a Flask release. Look for
|
||||||
ways in which your project can be refactored into a collection of utilities and
|
ways in which your project can be refactored into a collection of utilities and
|
||||||
Flask extensions. Explore the many `extensions
|
Flask extensions. Explore the many `extensions
|
||||||
<http://flask.pocoo.org/extensions/>` in the community, and look for patterns to
|
<http://flask.pocoo.org/extensions/>`_ in the community, and look for patterns to
|
||||||
build your own extensions if you do not find the tools you need.
|
build your own extensions if you do not find the tools you need.
|
||||||
|
|
||||||
Subclass.
|
Subclass.
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ A basic FastCGI configuration for lighttpd looks like that::
|
||||||
)
|
)
|
||||||
|
|
||||||
url.rewrite-once = (
|
url.rewrite-once = (
|
||||||
"^(/static.*)$" => "$1",
|
"^(/static($|/.*))$" => "$1",
|
||||||
"^(/.*)$" => "/yourapplication.fcgi$1"
|
"^(/.*)$" => "/yourapplication.fcgi$1"
|
||||||
|
|
||||||
Remember to enable the FastCGI, alias and rewrite modules. This configuration
|
Remember to enable the FastCGI, alias and rewrite modules. This configuration
|
||||||
|
|
|
||||||
|
|
@ -90,9 +90,9 @@ since decorators could be fired in undefined order when the application is
|
||||||
split into multiple modules.
|
split into multiple modules.
|
||||||
|
|
||||||
Another design decision with the Werkzeug routing system is that routes
|
Another design decision with the Werkzeug routing system is that routes
|
||||||
in Werkzeug try to ensure that there is that URLs are unique. Werkzeug
|
in Werkzeug try to ensure that URLs are unique. Werkzeug will go quite far
|
||||||
will go quite far with that in that it will automatically redirect to a
|
with that in that it will automatically redirect to a canonical URL if a route
|
||||||
canonical URL if a route is ambiguous.
|
is ambiguous.
|
||||||
|
|
||||||
|
|
||||||
One Template Engine
|
One Template Engine
|
||||||
|
|
|
||||||
|
|
@ -377,7 +377,7 @@ package it's actually inside your package:
|
||||||
/hello.html
|
/hello.html
|
||||||
|
|
||||||
For templates you can use the full power of Jinja2 templates. Head over
|
For templates you can use the full power of Jinja2 templates. Head over
|
||||||
to the the official `Jinja2 Template Documentation
|
to the official `Jinja2 Template Documentation
|
||||||
<http://jinja.pocoo.org/2/documentation/templates>`_ for more information.
|
<http://jinja.pocoo.org/2/documentation/templates>`_ for more information.
|
||||||
|
|
||||||
Here is an example template:
|
Here is an example template:
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,16 @@ for you to the application.
|
||||||
If you want to do that, you first have to import the
|
If you want to do that, you first have to import the
|
||||||
:func:`contextlib.closing` function from the contextlib package. If you
|
:func:`contextlib.closing` function from the contextlib package. If you
|
||||||
want to use Python 2.5 it's also necessary to enable the `with` statement
|
want to use Python 2.5 it's also necessary to enable the `with` statement
|
||||||
first (`__future__` imports must be the very first import)::
|
first (`__future__` imports must be the very first import). Accordingly,
|
||||||
|
add the following lines to your existing imports in `flaskr.py`::
|
||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
|
|
||||||
Next we can create a function called `init_db` that initializes the
|
Next we can create a function called `init_db` that initializes the
|
||||||
database. For this we can use the `connect_db` function we defined
|
database. For this we can use the `connect_db` function we defined
|
||||||
earlier. Just add that function below the `connect_db` function::
|
earlier. Just add that function below the `connect_db` function in
|
||||||
|
`flask.py`::
|
||||||
|
|
||||||
def init_db():
|
def init_db():
|
||||||
with closing(connect_db()) as db:
|
with closing(connect_db()) as db:
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
Introducing Flaskr
|
Introducing Flaskr
|
||||||
==================
|
==================
|
||||||
|
|
||||||
We will call our blogging application flaskr here, feel free to chose a
|
We will call our blogging application flaskr here, feel free to choose a
|
||||||
less web-2.0-ish name ;) Basically we want it to do the following things:
|
less web-2.0-ish name ;) Basically we want it to do the following things:
|
||||||
|
|
||||||
1. let the user sign in and out with credentials specified in the
|
1. let the user sign in and out with credentials specified in the
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ based view you would do this::
|
||||||
users = User.query.all()
|
users = User.query.all()
|
||||||
return render_template('users.html', objects=users)
|
return render_template('users.html', objects=users)
|
||||||
|
|
||||||
app.add_url_rule('/users/', ShowUsers.as_view('show_users'))
|
app.add_url_rule('/users/', view_func=ShowUsers.as_view('show_users'))
|
||||||
|
|
||||||
As you can see what you have to do is to create a subclass of
|
As you can see what you have to do is to create a subclass of
|
||||||
:class:`flask.views.View` and implement
|
:class:`flask.views.View` and implement
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
:license: BSD, see LICENSE for more details.
|
:license: BSD, see LICENSE for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__version__ = '0.9'
|
__version__ = '0.10-dev'
|
||||||
|
|
||||||
# utilities we import from Werkzeug and Jinja2 that are unused
|
# utilities we import from Werkzeug and Jinja2 that are unused
|
||||||
# in the module but are exported as public interface.
|
# in the module but are exported as public interface.
|
||||||
|
|
|
||||||
|
|
@ -1468,7 +1468,7 @@ class Flask(_PackageBoundObject):
|
||||||
|
|
||||||
.. versionchanged:: 0.9
|
.. versionchanged:: 0.9
|
||||||
This can now also be called without a request object when the
|
This can now also be called without a request object when the
|
||||||
UR adapter is created for the application context.
|
URL adapter is created for the application context.
|
||||||
"""
|
"""
|
||||||
if request is not None:
|
if request is not None:
|
||||||
return self.url_map.bind_to_environ(request.environ,
|
return self.url_map.bind_to_environ(request.environ,
|
||||||
|
|
|
||||||
|
|
@ -305,7 +305,9 @@ def url_for(endpoint, **values):
|
||||||
|
|
||||||
:param endpoint: the endpoint of the URL (name of the function)
|
:param endpoint: the endpoint of the URL (name of the function)
|
||||||
:param values: the variable arguments of the URL rule
|
:param values: the variable arguments of the URL rule
|
||||||
:param _external: if set to `True`, an absolute URL is generated.
|
:param _external: if set to `True`, an absolute URL is generated. Server
|
||||||
|
address can be changed via `SERVER_NAME` configuration variable which
|
||||||
|
defaults to `localhost`.
|
||||||
:param _anchor: if provided this is added as anchor to the URL.
|
:param _anchor: if provided this is added as anchor to the URL.
|
||||||
:param _method: if provided this explicitly specifies an HTTP method.
|
:param _method: if provided this explicitly specifies an HTTP method.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -77,7 +77,7 @@ class run_audit(Command):
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='Flask',
|
name='Flask',
|
||||||
version='0.9',
|
version='0.10-dev',
|
||||||
url='http://github.com/mitsuhiko/flask/',
|
url='http://github.com/mitsuhiko/flask/',
|
||||||
license='BSD',
|
license='BSD',
|
||||||
author='Armin Ronacher',
|
author='Armin Ronacher',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue