Skip to content
This repository
Browse code

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...
commit 5511a2a01322b66fefdc942e41c4d3d95b1f1677 1 parent c1a3c09
Keshav Kini authored April 01, 2013
4  flask_version/admin.py
... ...
@@ -1,7 +1,7 @@
1 1
 import os
2 2
 from flask import Module, url_for, render_template, request, session, redirect, g, current_app
3 3
 from decorators import login_required, admin_required, with_lock
4  
-from flaskext.babel import Babel, gettext, ngettext, lazy_gettext
  4
+from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext
5 5
 _ = gettext
6 6
 
7 7
 admin = Module('flask_version.admin')
@@ -107,7 +107,7 @@ def notebook_settings():
107 107
         
108 108
     #Make changes to the default language used
109 109
     if 'default_language' in request.values:
110  
-        from flaskext.babel import refresh
  110
+        from flask.ext.babel import refresh
111 111
         refresh()
112 112
         current_app.config['BABEL_DEFAULT_LOCALE'] = request.values['default_language']
113 113
         
2  flask_version/authentication.py
@@ -2,7 +2,7 @@
2 2
 import random
3 3
 from flask import Module, url_for, render_template, request, session, redirect, g, current_app
4 4
 from decorators import with_lock
5  
-from flaskext.babel import gettext, ngettext, lazy_gettext
  5
+from flask.ext.babel import gettext, ngettext, lazy_gettext
6 6
 _ = gettext
7 7
 
8 8
 authentication = Module('flask_version.authentication')
4  flask_version/base.py
@@ -5,10 +5,10 @@
5 5
 from decorators import login_required, guest_or_login_required, with_lock
6 6
 from decorators import global_lock
7 7
 
8  
-from flaskext.autoindex import AutoIndex
  8
+from flask.ext.autoindex import AutoIndex
9 9
 SRC = os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage', 'sage')
10 10
 from flask.ext.openid import OpenID
11  
-from flaskext.babel import Babel, gettext, ngettext, lazy_gettext, get_locale
  11
+from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext, get_locale
12 12
 from sagenb.misc.misc import SAGENB_ROOT, DATA, SAGE_DOC, translations_path
13 13
 
14 14
 oid = OpenID()
2  flask_version/decorators.py
... ...
@@ -1,6 +1,6 @@
1 1
 from functools import wraps
2 2
 from flask import Flask, url_for, render_template, request, session, redirect, g, current_app
3  
-from flaskext.babel import Babel, gettext, ngettext, lazy_gettext
  3
+from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext
4 4
 _ = gettext
5 5
 
6 6
 from threading import Lock
2  flask_version/worksheet.py
@@ -3,7 +3,7 @@
3 3
 from flask import Module, url_for, render_template, request, session, redirect, g, current_app
4 4
 from decorators import login_required, with_lock
5 5
 from collections import defaultdict
6  
-from flaskext.babel import Babel, gettext, ngettext, lazy_gettext
  6
+from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext
7 7
 _ = gettext
8 8
 
9 9
 from sagenb.notebook.interact import INTERACT_UPDATE_PREFIX
2  flask_version/worksheet_listing.py
@@ -4,7 +4,7 @@
4 4
 import urllib, urlparse
5 5
 from flask import Module, url_for, render_template, request, session, redirect, g, current_app
6 6
 from decorators import login_required, guest_or_login_required, with_lock
7  
-from flaskext.babel import Babel, gettext, ngettext, lazy_gettext
  7
+from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext
8 8
 _ = gettext
9 9
 
10 10
 worksheet_listing = Module('flask_version.worksheet_listing')
2  sagenb/notebook/challenge.py
@@ -27,7 +27,7 @@
27 27
 import os, random, re, urllib2, urllib
28 28
 
29 29
 from sagenb.notebook.template import template
30  
-from flaskext.babel import gettext, lazy_gettext
  30
+from flask.ext.babel import gettext, lazy_gettext
31 31
 _ = lazy_gettext
32 32
 
33 33
 class ChallengeResponse(object):
2  sagenb/notebook/conf.py
@@ -9,7 +9,7 @@
9 9
 #  The full text of the GPL is available at:
10 10
 #                  http://www.gnu.org/licenses/
11 11
 #############################################################################
12  
-from flaskext.babel import gettext, lazy_gettext
  12
+from flask.ext.babel import gettext, lazy_gettext
13 13
 
14 14
 POS = 'pos'
15 15
 DESC = 'desc'
2  sagenb/notebook/notebook.py
@@ -45,7 +45,7 @@
45 45
 from . import user_conf    # user configuration
46 46
 from . import user         # users
47 47
 from   template import template, prettify_time_ago
48  
-from flaskext.babel import gettext, lazy_gettext
  48
+from flask.ext.babel import gettext, lazy_gettext
49 49
 
50 50
 try:
51 51
     # sage is installed
2  sagenb/notebook/register.py
@@ -12,7 +12,7 @@
12 12
 """
13 13
 Helper functions dealing with the verification of user  
14 14
 """
15  
-from flaskext.babel import gettext as _
  15
+from flask.ext.babel import gettext as _
16 16
 
17 17
 def build_msg(key, username, addr, port, secure):
18 18
     url_prefix = "https" if secure else "http"
2  sagenb/notebook/server_conf.py
@@ -8,7 +8,7 @@
8 8
 from conf import (POS, DESC, GROUP, TYPE, CHOICES, T_BOOL, T_INTEGER,
9 9
                   T_CHOICE, T_REAL, T_COLOR, T_STRING, T_LIST, T_INFO)
10 10
 from sagenb.misc.misc import get_languages
11  
-from flaskext.babel import gettext, lazy_gettext
  11
+from flask.ext.babel import gettext, lazy_gettext
12 12
 _ = lazy_gettext
13 13
 
14 14
 defaults = {'word_wrap_cols':72,
2  sagenb/notebook/template.py
@@ -21,7 +21,7 @@
21 21
 
22 22
 from sagenb.misc.misc import SAGE_VERSION, DATA, unicode_str
23 23
 from sagenb.notebook.cell import number_of_rows
24  
-from flaskext.babel import gettext, ngettext, lazy_gettext
  24
+from flask.ext.babel import gettext, ngettext, lazy_gettext
25 25
 
26 26
 if os.environ.has_key('SAGENB_TEMPLATE_PATH'):
27 27
     if not os.path.isdir(os.environ['SAGENB_TEMPLATE_PATH']):
2  sagenb/notebook/tutorial.py
@@ -348,7 +348,7 @@ def f(n):
348 348
 
349 349
 #####################################
350 350
 
351  
-from flaskext.babel import lazy_gettext as _
  351
+from flask.ext.babel import lazy_gettext as _
352 352
 
353 353
 notebook_help = [
354 354
     (_('Find Help and Documentation'),
2  sagenb/notebook/user_conf.py
@@ -7,7 +7,7 @@
7 7
 from conf import (Configuration, POS, DESC, GROUP, TYPE, CHOICES, T_BOOL,
8 8
                   T_INTEGER, T_CHOICE, T_REAL, T_COLOR, T_STRING, T_LIST)
9 9
 from sagenb.misc.misc import SAGENB_ROOT, get_languages
10  
-from flaskext.babel import lazy_gettext
  10
+from flask.ext.babel import lazy_gettext
11 11
 
12 12
 defaults = {'max_history_length':1000,
13 13
             'default_system':'sage',
4  sagenb/notebook/worksheet.py
@@ -57,7 +57,7 @@
57 57
 # Imports specifically relevant to the sage notebook
58 58
 from cell import Cell, TextCell
59 59
 from template import template, clean_name, prettify_time_ago
60  
-from flaskext.babel import gettext, lazy_gettext
  60
+from flask.ext.babel import gettext, lazy_gettext
61 61
 _ = gettext
62 62
 
63 63
 # Set some constants that will be used for regular expressions below.
@@ -4288,7 +4288,7 @@ def convert_time_to_string(t):
4288 4288
     Converts ``t`` (in Unix time) to a locale-specific string
4289 4289
     describing the time and date.
4290 4290
     """
4291  
-    from flaskext.babel import format_datetime
  4291
+    from flask.ext.babel import format_datetime
4292 4292
     import datetime, time
4293 4293
     try:
4294 4294
         return format_datetime(datetime.datetime.fromtimestamp(float(t)))

0 notes on commit 5511a2a

Please sign in to comment.
Something went wrong with that request. Please try again.