Permalink
Browse files

Adapt to new Flask extension module schema

Naming your Flask extension module "flaskext.foo" is now discouraged in
favor of naming it "flask_foo". To accommodate both styles, Flask 0.8
and higher allows you to import "flask.ext.foo", which will first try
"flask_foo" and then try "flaskext.foo". We should do this for all our
flask extension imports.

In the short term, this allows sagenb to build against the latest
version of Flask-AutoIndex, i.e. it deals with the following commit:
sublee/flask-autoindex@2138855
  • Loading branch information...
1 parent c1a3c09 commit 5511a2a01322b66fefdc942e41c4d3d95b1f1677 @kini kini committed Apr 2, 2013
@@ -1,7 +1,7 @@
import os
from flask import Module, url_for, render_template, request, session, redirect, g, current_app
from decorators import login_required, admin_required, with_lock
-from flaskext.babel import Babel, gettext, ngettext, lazy_gettext
+from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext
_ = gettext
admin = Module('flask_version.admin')
@@ -107,7 +107,7 @@ def notebook_settings():
#Make changes to the default language used
if 'default_language' in request.values:
- from flaskext.babel import refresh
+ from flask.ext.babel import refresh
refresh()
current_app.config['BABEL_DEFAULT_LOCALE'] = request.values['default_language']
@@ -2,7 +2,7 @@
import random
from flask import Module, url_for, render_template, request, session, redirect, g, current_app
from decorators import with_lock
-from flaskext.babel import gettext, ngettext, lazy_gettext
+from flask.ext.babel import gettext, ngettext, lazy_gettext
_ = gettext
authentication = Module('flask_version.authentication')
@@ -5,10 +5,10 @@
from decorators import login_required, guest_or_login_required, with_lock
from decorators import global_lock
-from flaskext.autoindex import AutoIndex
+from flask.ext.autoindex import AutoIndex
SRC = os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage', 'sage')
from flask.ext.openid import OpenID
-from flaskext.babel import Babel, gettext, ngettext, lazy_gettext, get_locale
+from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext, get_locale
from sagenb.misc.misc import SAGENB_ROOT, DATA, SAGE_DOC, translations_path
oid = OpenID()
@@ -1,6 +1,6 @@
from functools import wraps
from flask import Flask, url_for, render_template, request, session, redirect, g, current_app
-from flaskext.babel import Babel, gettext, ngettext, lazy_gettext
+from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext
_ = gettext
from threading import Lock
@@ -3,7 +3,7 @@
from flask import Module, url_for, render_template, request, session, redirect, g, current_app
from decorators import login_required, with_lock
from collections import defaultdict
-from flaskext.babel import Babel, gettext, ngettext, lazy_gettext
+from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext
_ = gettext
from sagenb.notebook.interact import INTERACT_UPDATE_PREFIX
@@ -4,7 +4,7 @@
import urllib, urlparse
from flask import Module, url_for, render_template, request, session, redirect, g, current_app
from decorators import login_required, guest_or_login_required, with_lock
-from flaskext.babel import Babel, gettext, ngettext, lazy_gettext
+from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext
_ = gettext
worksheet_listing = Module('flask_version.worksheet_listing')
@@ -27,7 +27,7 @@
import os, random, re, urllib2, urllib
from sagenb.notebook.template import template
-from flaskext.babel import gettext, lazy_gettext
+from flask.ext.babel import gettext, lazy_gettext
_ = lazy_gettext
class ChallengeResponse(object):
@@ -9,7 +9,7 @@
# The full text of the GPL is available at:
# http://www.gnu.org/licenses/
#############################################################################
-from flaskext.babel import gettext, lazy_gettext
+from flask.ext.babel import gettext, lazy_gettext
POS = 'pos'
DESC = 'desc'
@@ -45,7 +45,7 @@
from . import user_conf # user configuration
from . import user # users
from template import template, prettify_time_ago
-from flaskext.babel import gettext, lazy_gettext
+from flask.ext.babel import gettext, lazy_gettext
try:
# sage is installed
@@ -12,7 +12,7 @@
"""
Helper functions dealing with the verification of user
"""
-from flaskext.babel import gettext as _
+from flask.ext.babel import gettext as _
def build_msg(key, username, addr, port, secure):
url_prefix = "https" if secure else "http"
@@ -8,7 +8,7 @@
from conf import (POS, DESC, GROUP, TYPE, CHOICES, T_BOOL, T_INTEGER,
T_CHOICE, T_REAL, T_COLOR, T_STRING, T_LIST, T_INFO)
from sagenb.misc.misc import get_languages
-from flaskext.babel import gettext, lazy_gettext
+from flask.ext.babel import gettext, lazy_gettext
_ = lazy_gettext
defaults = {'word_wrap_cols':72,
@@ -21,7 +21,7 @@
from sagenb.misc.misc import SAGE_VERSION, DATA, unicode_str
from sagenb.notebook.cell import number_of_rows
-from flaskext.babel import gettext, ngettext, lazy_gettext
+from flask.ext.babel import gettext, ngettext, lazy_gettext
if os.environ.has_key('SAGENB_TEMPLATE_PATH'):
if not os.path.isdir(os.environ['SAGENB_TEMPLATE_PATH']):
@@ -348,7 +348,7 @@ def f(n):
#####################################
-from flaskext.babel import lazy_gettext as _
+from flask.ext.babel import lazy_gettext as _
notebook_help = [
(_('Find Help and Documentation'),
@@ -7,7 +7,7 @@
from conf import (Configuration, POS, DESC, GROUP, TYPE, CHOICES, T_BOOL,
T_INTEGER, T_CHOICE, T_REAL, T_COLOR, T_STRING, T_LIST)
from sagenb.misc.misc import SAGENB_ROOT, get_languages
-from flaskext.babel import lazy_gettext
+from flask.ext.babel import lazy_gettext
defaults = {'max_history_length':1000,
'default_system':'sage',
@@ -57,7 +57,7 @@
# Imports specifically relevant to the sage notebook
from cell import Cell, TextCell
from template import template, clean_name, prettify_time_ago
-from flaskext.babel import gettext, lazy_gettext
+from flask.ext.babel import gettext, lazy_gettext
_ = gettext
# Set some constants that will be used for regular expressions below.
@@ -4288,7 +4288,7 @@ def convert_time_to_string(t):
Converts ``t`` (in Unix time) to a locale-specific string
describing the time and date.
"""
- from flaskext.babel import format_datetime
+ from flask.ext.babel import format_datetime
import datetime, time
try:
return format_datetime(datetime.datetime.fromtimestamp(float(t)))

0 comments on commit 5511a2a

Please sign in to comment.