Skip to content

Commit

Permalink
Merge pull request #96 from jeffwidman/fix-flask-ext-import-syntax
Browse files Browse the repository at this point in the history
Use flask_* instead of deprecated flask.ext.*
  • Loading branch information
rpicard committed Mar 18, 2016
2 parents 47b6e6d + c2ec25c commit 13bb942
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion source/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ define a form in a ``myapp.forms`` package.

.. note::

Until version 0.9, Flask-WTF provided its own wrappers around the WTForms fields and validators. You may see a lot of code out in the wild that imports ``TextField``, ``PasswordField``, etc. from ``flask.ext.wtforms`` instead of ``wtforms``.
Until version 0.9, Flask-WTF provided its own wrappers around the WTForms fields and validators. You may see a lot of code out in the wild that imports ``TextField``, ``PasswordField``, etc. from ``flask_wtforms`` instead of ``wtforms``.

As of 0.9, we should be importing that stuff straight from ``wtforms``.

Expand Down
2 changes: 1 addition & 1 deletion source/static.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ We'll put these in an assets module inside our ``util`` package.

# myapp/util/assets.py

from flask.ext.assets import Bundle, Environment
from flask_assets import Bundle, Environment
from .. import app

bundles = {
Expand Down
6 changes: 3 additions & 3 deletions source/storing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ configure some SQLAlchemy. The models are going to go in
# ourapp/__init__.py

from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__, instance_relative_config=True)

Expand All @@ -73,7 +73,7 @@ models.

# ourapp/models.py

from . import db
from . import db

class Engine(db.Model):

Expand Down Expand Up @@ -124,7 +124,7 @@ Let's open up a Python terminal in our repository root.
/Users/me/Code/myapp
$ workon myapp
(myapp)$ python
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from myapp import db
Expand Down
10 changes: 5 additions & 5 deletions source/users.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ encodings before comparing hashes).

# ourapp/__init__.py

from flask.ext.bcrypt import Bcrypt
from flask_bcrypt import Bcrypt

bcrypt = Bcrypt(app)

Expand Down Expand Up @@ -213,7 +213,7 @@ script that, well, hashes a password.

# benchmark.py

from flask.ext.bcrypt import generate_password_hash
from flask_bcrypt import generate_password_hash

# Change the number of rounds (second argument) until it takes between
# 0.25 and 0.5 seconds to run.
Expand Down Expand Up @@ -358,7 +358,7 @@ In *\_\_init\_\_.py* we'll define the Flask-Login ``login_manager``.

# ourapp/__init__.py

from flask.ext.login import LoginManager
from flask_login import LoginManager

# Create and configure app
# [...]
Expand Down Expand Up @@ -390,7 +390,7 @@ Now we can define the ``signin`` view that will handle authentication.

from flask import redirect, url_for

from flask.ext.login import login_user
from flask_login import login_user

from . import app
from .forms import UsernamePasswordForm
Expand Down Expand Up @@ -418,7 +418,7 @@ current user out with ``logout_user()``.
# ourapp/views.py

from flask import redirect, url_for
from flask.ext.login import logout_user
from flask_login import logout_user

from . import app

Expand Down
10 changes: 5 additions & 5 deletions source/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ gives us a decorator to restrict certain views to authenticated users:
# app.py

from flask import render_template
from flask.ext.login import login_required, current_user
from flask_login import login_required, current_user


@app.route('/')
Expand Down Expand Up @@ -93,7 +93,7 @@ decorated view would look like.

# app.py

from flask.ext.cache import Cache
from flask_cache import Cache
from flask import Flask

app = Flask()
Expand All @@ -107,7 +107,7 @@ decorated view would look like.
[...] # Make a few database calls to get the information we need
return render_template(
'index.html',
latest_posts=latest_posts,
latest_posts=latest_posts,
recent_users=recent_users,
recent_photos=recent_photos
)
Expand Down Expand Up @@ -136,7 +136,7 @@ the billing page and tell them to upgrade.

from flask import flash, redirect, url_for

from flask.ext.login import current_user
from flask_login import current_user

def check_expired(func):
@wraps(func)
Expand Down Expand Up @@ -199,7 +199,7 @@ use multiple decorators by stacking them.

from flask import render_template

from flask.ext.login import login_required
from flask_login import login_required

from . import app
from .util import check_expired
Expand Down

0 comments on commit 13bb942

Please sign in to comment.