diff --git a/realms/__init__.py b/realms/__init__.py index 57779ac..8a9bda1 100644 --- a/realms/__init__.py +++ b/realms/__init__.py @@ -17,6 +17,7 @@ from flask.ext.login import LoginManager, current_user from flask.ext.sqlalchemy import SQLAlchemy from flask.ext.assets import Environment, Bundle from flask_ldap_login import LDAPLoginManager +from functools import update_wrapper from werkzeug.routing import BaseConverter from werkzeug.exceptions import HTTPException from sqlalchemy.ext.declarative import declarative_base @@ -111,12 +112,14 @@ class Assets(Environment): return super(Assets, self).register(name, Bundle(*args, filters=filters, output=output)) + class MyLDAPLoginManager(LDAPLoginManager): @property def attrlist(self): # the parent method doesn't always work return None + class RegexConverter(BaseConverter): """ Enables Regex matching on endpoints """ @@ -243,8 +246,6 @@ assets.register('main.css', 'css/style.css') -from functools import update_wrapper - def with_appcontext(f): """Wraps a callback so that it's guaranteed to be executed with the script's application context. If callbacks are registered directly @@ -288,6 +289,7 @@ class AppGroup(click.Group): flask_cli = AppGroup() + @flask_cli.group() def cli(): pass diff --git a/realms/commands.py b/realms/commands.py index 326d67d..1b266f7 100644 --- a/realms/commands.py +++ b/realms/commands.py @@ -291,7 +291,8 @@ def configure(json_string): @cli.command() @click.option('--port', default=config.PORT) -def dev(port): +@click.option('--host', default=config.HOST) +def dev(port, host): """ Run development server """ green("Starting development server") @@ -302,7 +303,7 @@ def dev(port): else: yellow("Using default configuration") - create_app().run(host="0.0.0.0", + create_app().run(host=host, port=port, debug=True) @@ -332,8 +333,8 @@ def start_server(): if in_virtualenv(): prefix = get_prefix() + "/bin/" - Popen("%sgunicorn 'realms:create_app()' -b 0.0.0.0:%s -k gevent %s" % - (prefix, config.PORT, flags), shell=True, executable='/bin/bash') + Popen("%sgunicorn 'realms:create_app()' -b %s:%s -k gevent %s" % + (config.HOST, prefix, config.PORT, flags), shell=True, executable='/bin/bash') def stop_server(): diff --git a/realms/config/__init__.py b/realms/config/__init__.py index 3dba1a8..3bb8644 100644 --- a/realms/config/__init__.py +++ b/realms/config/__init__.py @@ -3,6 +3,7 @@ import json from urlparse import urlparse from realms.lib.util import in_vagrant + def update(data): conf = read() conf.update(data) @@ -72,6 +73,7 @@ DEBUG = True ASSETS_DEBUG = True SQLALCHEMY_ECHO = False +HOST = "0.0.0.0" PORT = 5000 BASE_URL = 'http://localhost' SITE_TITLE = "Realms"