summaryrefslogtreecommitdiffstats
path: root/accounts/utils/console.py
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/utils/console.py')
-rw-r--r--accounts/utils/console.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/accounts/utils/console.py b/accounts/utils/console.py
index f81bd36..9996faa 100644
--- a/accounts/utils/console.py
+++ b/accounts/utils/console.py
@@ -1,4 +1,22 @@
# -*- coding: utf-8 -*-
+from flask.ext import script
+
+
+class Command(script.Command):
+ """
+ This changes the Command class from Flask-Script in such way,
+ that url_for will generate correct urls.
+ """
+
+ def __call__(self, app=None, *args, **kwargs):
+ base_url = '%s://%s%s' % (
+ app.config.get('PREFERRED_URL_SCHEME') or 'http',
+ app.config.get('SERVER_NAME') or 'localhost',
+ app.config.get('APPLICATION_ROOT') or '/')
+
+ with app.test_request_context(base_url=base_url):
+ return self.run(*args, **kwargs)
+
class TablePrinter(object):