Browse Source

Use jinja to generate the config file

Peter Justin 8 years ago
parent
commit
07ad194f67

+ 1 - 0
.gitignore

@@ -44,6 +44,7 @@ __pycache__
 *.iml
 *.iml
 flaskbb/configs/production.py
 flaskbb/configs/production.py
 flaskbb/configs/development.py
 flaskbb/configs/development.py
+flaskbb/configs/*.cfg
 .tox
 .tox
 *.rdb
 *.rdb
 .cache
 .cache

+ 67 - 32
flaskbb/cli/main.py

@@ -16,6 +16,7 @@ import binascii
 
 
 import click
 import click
 from werkzeug.utils import import_string, ImportStringError
 from werkzeug.utils import import_string, ImportStringError
+from jinja2 import Environment, FileSystemLoader
 from flask import current_app
 from flask import current_app
 from flask.cli import FlaskGroup, ScriptInfo, with_appcontext
 from flask.cli import FlaskGroup, ScriptInfo, with_appcontext
 from sqlalchemy_utils.functions import database_exists, create_database, drop_database
 from sqlalchemy_utils.functions import database_exists, create_database, drop_database
@@ -411,88 +412,122 @@ def list_urls(order_by):
               help="Creates a development config with DEBUG set to True.")
               help="Creates a development config with DEBUG set to True.")
 @click.option("--output", "-o", default=".",
 @click.option("--output", "-o", default=".",
               help="The path where the config file will be saved at.")
               help="The path where the config file will be saved at.")
-def generate_config(debug, output):
-    configvars = {"is_debug": debug}
+@click.option("--stdout", default=False, is_flag=True,
+              help="This will ignore --output and print the config to stdout.")
+def generate_config(debug, output, stdout):
+    config_dict = {"is_debug": debug}
 
 
     click.secho("The name and port number of the server.\n"
     click.secho("The name and port number of the server.\n"
                 "This is needed to correctly generate URLs when no request "
                 "This is needed to correctly generate URLs when no request "
                 "context is available.", fg="cyan")
                 "context is available.", fg="cyan")
-    configvars["server_name"] = click.prompt(
+    config_dict["server_name"] = click.prompt(
         click.style("Server Name", fg="magenta"), type=str,
         click.style("Server Name", fg="magenta"), type=str,
         default="forums.flaskbb.org")
         default="forums.flaskbb.org")
 
 
     click.secho("The URL Scheme is also needed in order to generate correct "
     click.secho("The URL Scheme is also needed in order to generate correct "
                 "URLs when no request context is available.\n"
                 "URLs when no request context is available.\n"
                 "Choose either 'https' or 'http'.", fg="cyan")
                 "Choose either 'https' or 'http'.", fg="cyan")
-    configvars["url_scheme"] = click.prompt(
+    config_dict["url_scheme"] = click.prompt(
         click.style("URL Scheme", fg="magenta"),
         click.style("URL Scheme", fg="magenta"),
         type=click.Choice(["https", "http"]), default="https")
         type=click.Choice(["https", "http"]), default="https")
 
 
+    config_dict["secret_key"] = binascii.hexlify(os.urandom(24)).decode()
+    config_dict["csrf_secret_key"] = binascii.hexlify(os.urandom(24)).decode()
+
     click.secho("For Postgres use:\n"
     click.secho("For Postgres use:\n"
                 "    postgresql://flaskbb@localhost:5432/flaskbb\n"
                 "    postgresql://flaskbb@localhost:5432/flaskbb\n"
                 "For more options see the SQLAlchemy docs:\n"
                 "For more options see the SQLAlchemy docs:\n"
                 "    http://docs.sqlalchemy.org/en/latest/core/engines.html",
                 "    http://docs.sqlalchemy.org/en/latest/core/engines.html",
                 fg="cyan")
                 fg="cyan")
-    configvars["database_url"] = click.prompt(
+    config_dict["database_url"] = click.prompt(
         click.style("Database URI", fg="magenta"),
         click.style("Database URI", fg="magenta"),
         default="sqlite:///" + os.path.join(
         default="sqlite:///" + os.path.join(
             os.path.dirname(current_app.root_path), "flaskbb.sqlite"))
             os.path.dirname(current_app.root_path), "flaskbb.sqlite"))
 
 
     click.secho("Redis will be used for things such as the task queue, "
     click.secho("Redis will be used for things such as the task queue, "
                 "caching and rate limiting.", fg="cyan")
                 "caching and rate limiting.", fg="cyan")
-    configvars["use_redis"] = click.confirm(
+    config_dict["redis_enabled"] = click.confirm(
         click.style("Would you like to use redis?", fg="magenta"),
         click.style("Would you like to use redis?", fg="magenta"),
         default=True)
         default=True)
 
 
-    if configvars.get("use_redis", False):
-        configvars["redis_url"] = click.prompt(
+    if config_dict.get("redis_enabled", False):
+        config_dict["redis_url"] = click.prompt(
             click.style("Redis URI", fg="magenta"),
             click.style("Redis URI", fg="magenta"),
             default="redis://localhost:6379")
             default="redis://localhost:6379")
     else:
     else:
-        configvars["redis_url"] = ""
+        config_dict["redis_url"] = ""
 
 
     click.secho("To use 'localhost' make sure that you have sendmail or\n"
     click.secho("To use 'localhost' make sure that you have sendmail or\n"
-                "anything similar installed. Gmail is also supprted.",
+                "something similar installed. Gmail is also supprted.",
                 fg="cyan")
                 fg="cyan")
-    configvars["mail_server"] = click.prompt(
+    config_dict["mail_server"] = click.prompt(
         click.style("Mail Server", fg="magenta"),
         click.style("Mail Server", fg="magenta"),
         default="localhost")
         default="localhost")
-    configvars["mail_port"] = click.prompt(
+    click.secho("The port on which the SMTP server is listening on.", fg="cyan")
+    config_dict["mail_port"] = click.prompt(
         click.style("Mail Server SMTP Port", fg="magenta"),
         click.style("Mail Server SMTP Port", fg="magenta"),
         default="25")
         default="25")
-    configvars["mail_use_ssl"] = click.confirm(
-        click.style("Use SSL for sending mails?", fg="magenta"),
-        default=False)
-    configvars["mail_use_tls"] = click.confirm(
+    click.secho("If you are using a local SMTP server like sendmail this is "
+                "not needed. For external servers this is hopefully required.",
+                fg="cyan")
+    config_dict["mail_use_tls"] = click.confirm(
         click.style("Use TLS for sending mails?", fg="magenta"),
         click.style("Use TLS for sending mails?", fg="magenta"),
         default=False)
         default=False)
-    configvars["mail_username"] = click.prompt(
+    click.secho("Same as above. TLS is the successor to SSL.", fg="cyan")
+    config_dict["mail_use_ssl"] = click.confirm(
+        click.style("Use SSL for sending mails?", fg="magenta"),
+        default=False)
+    click.secho("Not needed if using a local smtp server. For gmail you have "
+                "put in your email address here.", fg="cyan")
+    config_dict["mail_username"] = click.prompt(
         click.style("Mail Username", fg="magenta"),
         click.style("Mail Username", fg="magenta"),
         default="")
         default="")
-    configvars["mail_password"] = click.prompt(
+    click.secho("Not needed if using a local smtp server. For gmail you have "
+            "put in your gmail password here.", fg="cyan")
+    config_dict["mail_password"] = click.prompt(
         click.style("Mail Password", fg="magenta"),
         click.style("Mail Password", fg="magenta"),
         default="")
         default="")
-    configvars["mail_sender_name"] = click.prompt(
+    click.secho("The name of the sender. You probably want to change it to "
+                "something like '<your_community> Mailer'.", fg="cyan")
+    config_dict["mail_sender_name"] = click.prompt(
         click.style("Mail Sender Name", fg="magenta"),
         click.style("Mail Sender Name", fg="magenta"),
         default="FlaskBB Mailer")
         default="FlaskBB Mailer")
-    configvars["mail_sender_address"] = click.prompt(
+    click.secho("On localhost you want to use a noreply address here. "
+                "Use your email address for gmail here.", fg="cyan")
+    config_dict["mail_sender_address"] = click.prompt(
         click.style("Mail Sender Address", fg="magenta"),
         click.style("Mail Sender Address", fg="magenta"),
         default="noreply@yourdomain.org")
         default="noreply@yourdomain.org")
-    configvars["mail_admin_address"] = click.prompt(
+    click.secho("Logs and important system messages are sent to this address."
+                "Use your email address for gmail here.", fg="cyan")
+    config_dict["mail_admin_address"] = click.prompt(
         click.style("Mail Admin Email", fg="magenta"),
         click.style("Mail Admin Email", fg="magenta"),
         default="admin@youremailaddress.org")
         default="admin@youremailaddress.org")
 
 
-    config_path = os.path.join(
-        os.path.dirname(current_app.root_path), "flaskbb.cfg"
+    config_env = Environment(
+        loader=FileSystemLoader(os.path.join(current_app.root_path, "configs"))
     )
     )
-    configvars["config_path"] = click.prompt(
-        click.style("Output Path", fg="magenta"),
-        default=config_path)
+    config_template = config_env.get_template('config.cfg.template')
 
 
-    click.secho("The configuration file has been saved to: {cfg}\n"
-                "You can use it like this: flaskbb --config {cfg} run\n"
-                "Feel free to further adjust it as needed."
-                .format(cfg=config_path), fg="green")
+    if not stdout:
+        config_path = os.path.join(
+            os.path.dirname(current_app.root_path), "flaskbb.cfg"
+        )
+        click.secho("The path where you want to save this configuration file.",
+                    fg="cyan")
+        config_dict["config_path"] = click.prompt(
+            click.style("Output Path", fg="magenta"),
+            default=config_path)
+
+        if os.path.exists(config_dict["config_path"]) and click.confirm(
+            click.style("Config file already exists. "
+                        "Do you want to overwride it?")):
+            pass
 
 
-    configvars["secret_key"] = binascii.hexlify(os.urandom(24)).decode()
-    configvars["csrf_secret_key"] = binascii.hexlify(os.urandom(24)).decode()
+        click.secho("The configuration file has been saved to: {cfg}"
+                    .format(cfg=config_dict["config_path"]), fg="blue")
+
+        click.secho("Use it like this: flaskbb --config {cfg} run\n"
+                    "Feel free to adjust it as needed."
+                    .format(cfg=config_dict["config_path"]), fg="green")
+    else:
+        click.echo(config_template.render(**config_dict))

+ 0 - 158
flaskbb/cli/utils.py

@@ -137,161 +137,3 @@ def get_version(ctx, param, value):
         'python_version': sys.version.split("\n")[0]
         'python_version': sys.version.split("\n")[0]
     }, color=ctx.color)
     }, color=ctx.color)
     ctx.exit()
     ctx.exit()
-
-
-CONFIG_TEMPLATE = """
-import os
-import datetime
-from flaskbb.configs.default import DefaultConfig
-
-# Flask Settings
-# ------------------------------
-# There is a whole bunch of more settings available here:
-# http://flask.pocoo.org/docs/0.11/config/#builtin-configuration-values
-DEBUG = {is_debug}
-TESTING = False
-
-# Server Name - REQUIRED for Celery/Mailing
-# The name and port number of the server.
-# Required for subdomain support (e.g.: 'myapp.dev:5000') and
-# URL generation without a request context but with an application context
-# which we need in order to generate URLs (with the celery application)
-# Note that localhost does not support subdomains so setting this to
-# “localhost” does not help.
-# Example for the FlaskBB forums: SERVER_NAME = "forums.flaskbb.org"
-SERVER_NAME = {server_name}
-
-# Prefer HTTPS over HTTP
-PREFERRED_URL_SCHEME = "{url_scheme}"
-
-# If SEND_LOGS is set to True, the admins (see the mail configuration) will
-# recieve the error logs per email.
-SEND_LOGS = False
-
-# The filename for the info and error logs. The logfiles are stored at
-# flaskbb/logs
-INFO_LOG = "info.log"
-ERROR_LOG = "error.log"
-
-# Database
-# ------------------------------
-#SQLALCHEMY_DATABASE_URI = "{database_url}"
-
-# This option will be removed as soon as Flask-SQLAlchemy removes it.
-# At the moment it is just used to suppress the super annoying warning
-SQLALCHEMY_TRACK_MODIFICATIONS = False
-# This will print all SQL statements
-SQLALCHEMY_ECHO = False
-
-# Security - IMPORTANT
-# ------------------------------
-# This is the secret key that is used for session signing.
-# You can generate a secure key with os.urandom(24)
-SECRET_KEY = "{secret_key}"
-
-# You can generate the WTF_CSRF_SECRET_KEY the same way as you have
-# generated the SECRET_KEY. If no WTF_CSRF_SECRET_KEY is provided, it will
-# use the SECRET_KEY.
-WTF_CSRF_ENABLED = True
-WTF_CSRF_SECRET_KEY = "{csrf_secret_key}"
-
-# Full-Text-Search
-# ------------------------------
-# This will use the "whoosh_index" directory to store the search indexes
-WHOOSHEE_DIR = os.path.join(DefaultConfig._basedir, "whoosh_index", DefaultConfig._version_str)
-# How long should whooshee try to acquire write lock? (defaults to 2)
-WHOOSHEE_WRITER_TIMEOUT = 2
-# Minimum number of characters for the search (defaults to 3)
-WHOOSHEE_MIN_STRING_LEN = 3
-
-# Auth
-# ------------------------------
-LOGIN_VIEW = "auth.login"
-REAUTH_VIEW = "auth.reauth"
-LOGIN_MESSAGE_CATEGORY = "info"
-REFRESH_MESSAGE_CATEGORY = "info"
-
-# The name of the cookie to store the “remember me” information in.
-REMEMBER_COOKIE_NAME = "remember_token"
-# The amount of time before the cookie expires, as a datetime.timedelta object.
-# Default: 365 days (1 non-leap Gregorian year)
-REMEMBER_COOKIE_DURATION = datetime.timedelta(days=365)
-# If the “Remember Me” cookie should cross domains,
-# set the domain value here (i.e. .example.com would allow the cookie
-# to be used on all subdomains of example.com).
-REMEMBER_COOKIE_DOMAIN = None
-# Limits the “Remember Me” cookie to a certain path.
-REMEMBER_COOKIE_PATH = "/"
-# Restricts the “Remember Me” cookie’s scope to secure channels (typically HTTPS).
-REMEMBER_COOKIE_SECURE = None
-# Prevents the “Remember Me” cookie from being accessed by client-side scripts.
-REMEMBER_COOKIE_HTTPONLY = False
-
-# Redis
-# ------------------------------
-# If redis is enabled, it can be used for:
-#   - Sending non blocking emails via Celery (Task Queue)
-#   - Caching
-#   - Rate Limiting
-REDIS_ENABLED = {use_redis}
-REDIS_URL = {redis_url}
-REDIS_DATABASE = 0
-
-# Celery
-# ------------------------------
-CELERY_BROKER_URL = REDIS_URL
-CELERY_RESULT_BACKEND = REDIS_URL
-
-# Rate Limiting via Flask-Limiter
-# -------------------------------
-# A full list with configuration values is available at the flask-limiter
-# docs, but you actually just need those settings below.
-# You can disabled the Rate Limiter here as well - it will overwrite
-# the setting from the admin panel!
-# RATELIMIT_ENABLED = True
-# You can choose from:
-#   memory:// (default)
-#   redis://host:port
-#   memcached://host:port
-# Using the redis storage requires the installation of the redis package,
-# which will be installed if you enable REDIS_ENABLE while memcached
-# relies on the pymemcache package.
-RATELIMIT_STORAGE_URL = REDIS_URL
-
-# Caching
-# ------------------------------
-# For all available caching types, have a look at the Flask-Cache docs
-# https://pythonhosted.org/Flask-Caching/#configuring-flask-caching
-CACHE_TYPE = "simple" if not REDIS_ENABLED else "redis"
-CACHE_DEFAULT_TIMEOUT = 60
-
-# Mail
-# ------------------------------
-# Google Mail Example
-#MAIL_SERVER = "smtp.gmail.com"
-#MAIL_PORT = 465
-#MAIL_USE_SSL = True
-#MAIL_USERNAME = "your_username@gmail.com"
-#MAIL_PASSWORD = "your_password"
-#MAIL_DEFAULT_SENDER = ("Your Name", "your_username@gmail.com")
-
-# Local SMTP Server
-MAIL_SERVER = "{mail_server}"
-MAIL_PORT = {mail_port}
-MAIL_USE_SSL = {mail_use_ssl}
-MAIL_USE_TLS = {mail_use_tls}
-MAIL_USERNAME = "{mail_username}"
-MAIL_PASSWORD = "{mail_password}"
-MAIL_DEFAULT_SENDER = ("{mail_sender_name}", "{mail_sender_address}")
-# Where to logger should send the emails to
-ADMINS = ["{mail_admin_address}"]
-
-# FlaskBB Settings
-# ------------------------------ #
-# URL Prefixes
-FORUM_URL_PREFIX = ""
-USER_URL_PREFIX = "/user"
-MESSAGE_URL_PREFIX = "/message"
-AUTH_URL_PREFIX = "/auth"
-ADMIN_URL_PREFIX = "/admin"
-"""

+ 164 - 0
flaskbb/configs/config.cfg.template

@@ -0,0 +1,164 @@
+import os
+import datetime
+from flaskbb.configs.default import DefaultConfig
+
+
+# Flask Settings
+# ------------------------------
+# There is a whole bunch of more settings available here:
+# http://flask.pocoo.org/docs/0.11/config/#builtin-configuration-values
+DEBUG = {{ is_debug }}
+TESTING = False
+
+# Server Name - REQUIRED for Celery/Mailing
+# The name and port number of the server.
+# Required for subdomain support (e.g.: 'myapp.dev:5000') and
+# URL generation without a request context but with an application context
+# which we need in order to generate URLs (with the celery application)
+# Note that localhost does not support subdomains so setting this to
+# “localhost” does not help.
+# Example for the FlaskBB forums: SERVER_NAME = "forums.flaskbb.org"
+SERVER_NAME = "{{ server_name }}"
+
+# Prefer HTTPS over HTTP
+PREFERRED_URL_SCHEME = "{{ url_scheme }}"
+
+
+# Database
+# ------------------------------
+# For PostgresSQL:
+#SQLALCHEMY_DATABASE_URI = "postgresql://flaskbb@localhost:5432/flaskbb"
+# For SQLite:
+SQLALCHEMY_DATABASE_URI = "{{ database_url }}"
+
+# This option will be removed as soon as Flask-SQLAlchemy removes it.
+# At the moment it is just used to suppress the super annoying warning
+SQLALCHEMY_TRACK_MODIFICATIONS = False
+# This will print all SQL statements
+SQLALCHEMY_ECHO = False
+
+
+# Security - IMPORTANT
+# ------------------------------
+# This is the secret key that is used for session signing.
+# You can generate a secure key with os.urandom(24)
+SECRET_KEY = "{{ secret_key }}"
+
+# You can generate the WTF_CSRF_SECRET_KEY the same way as you have
+# generated the SECRET_KEY. If no WTF_CSRF_SECRET_KEY is provided, it will
+# use the SECRET_KEY.
+WTF_CSRF_ENABLED = True
+WTF_CSRF_SECRET_KEY = "{{ csrf_secret_key }}"
+
+
+# Auth
+# ------------------------------
+LOGIN_VIEW = "auth.login"
+REAUTH_VIEW = "auth.reauth"
+LOGIN_MESSAGE_CATEGORY = "info"
+REFRESH_MESSAGE_CATEGORY = "info"
+
+# The name of the cookie to store the “remember me” information in.
+REMEMBER_COOKIE_NAME = "remember_token"
+# The amount of time before the cookie expires, as a datetime.timedelta object.
+# Default: 365 days (1 non-leap Gregorian year)
+REMEMBER_COOKIE_DURATION = datetime.timedelta(days=365)
+# If the “Remember Me” cookie should cross domains,
+# set the domain value here (i.e. .example.com would allow the cookie
+# to be used on all subdomains of example.com).
+REMEMBER_COOKIE_DOMAIN = None
+# Limits the “Remember Me” cookie to a certain path.
+REMEMBER_COOKIE_PATH = "/"
+# Restricts the “Remember Me” cookie’s scope to secure channels (typically HTTPS).
+REMEMBER_COOKIE_SECURE = None
+# Prevents the “Remember Me” cookie from being accessed by client-side scripts.
+REMEMBER_COOKIE_HTTPONLY = False
+
+
+# Full-Text-Search
+# ------------------------------
+# This will use the "whoosh_index" directory to store the search indexes
+WHOOSHEE_DIR = os.path.join(DefaultConfig.basedir, "whoosh_index", DefaultConfig.py_version)
+# How long should whooshee try to acquire write lock? (defaults to 2)
+WHOOSHEE_WRITER_TIMEOUT = 2
+# Minimum number of characters for the search (defaults to 3)
+WHOOSHEE_MIN_STRING_LEN = 3
+
+
+# Redis
+# ------------------------------
+# If redis is enabled, it can be used for:
+#   - Sending non blocking emails via Celery (Task Queue)
+#   - Caching
+#   - Rate Limiting
+REDIS_ENABLED = {{ redis_enabled }}
+REDIS_URL = "{{ redis_url }}"
+REDIS_DATABASE = 0
+
+
+# Celery
+# ------------------------------
+CELERY_BROKER_URL = "{{ redis_url }}"
+CELERY_RESULT_BACKEND = "{{ redis_url }}"
+
+
+# Rate Limiting
+# -------------------------------
+# A full list with configuration values is available at the flask-limiter
+# docs, but you actually just need those settings below.
+# You can disabled the Rate Limiter here as well - it will overwrite
+# the setting from the admin panel!
+# RATELIMIT_ENABLED = True
+# You can choose from:
+#   memory:// (default)
+#   redis://host:port
+#   memcached://host:port
+# Using the redis storage requires the installation of the redis package,
+# which will be installed if you enable REDIS_ENABLE while memcached
+# relies on the pymemcache package.
+RATELIMIT_STORAGE_URL = "{% if redis_enabled %}{{ redis_url }}{% else %}memory://{% endif %}"
+
+
+# Caching
+# ------------------------------
+# For all available caching types, have a look at the Flask-Cache docs
+# https://pythonhosted.org/Flask-Caching/#configuring-flask-caching
+CACHE_TYPE = "{% if redis_enabled %}redis{% else %}simple{% endif %}"
+CACHE_DEFAULT_TIMEOUT = 60
+
+
+# Mail
+# ------------------------------
+# Google Mail Example
+# https://support.google.com/mail/answer/7126229?hl=en
+#MAIL_SERVER = "smtp.gmail.com"
+#MAIL_PORT = 587
+#MAIL_USE_TLS = True
+#MAIL_USE_SSL = True
+#MAIL_USERNAME = "your_username@gmail.com"
+#MAIL_PASSWORD = "your_password"
+#MAIL_DEFAULT_SENDER = ("Your Name", "your_username@gmail.com")
+
+# Local SMTP Server
+MAIL_SERVER = "{{ mail_server }}"
+MAIL_PORT = {{ mail_port }}
+MAIL_USE_SSL = {{ mail_use_ssl }}
+MAIL_USE_TLS = {{ mail_use_tls }}
+MAIL_USERNAME = "{{ mail_username }}"
+MAIL_PASSWORD = "{{ mail_password }}"
+MAIL_DEFAULT_SENDER = ("{{ mail_sender_name }}", "{{ mail_sender_address }}")
+# Where to logger should send the emails to
+ADMINS = ["{{ mail_admin_address }}"]
+# If SEND_LOGS is set to True, the admins (see the mail configuration) will
+# recieve the error logs per email.
+SEND_LOGS = False
+
+
+# FlaskBB Settings
+# ------------------------------ #
+# URL Prefixes
+FORUM_URL_PREFIX = ""
+USER_URL_PREFIX = "/user"
+MESSAGE_URL_PREFIX = "/message"
+AUTH_URL_PREFIX = "/auth"
+ADMIN_URL_PREFIX = "/admin"

+ 7 - 7
flaskbb/configs/default.py

@@ -19,11 +19,11 @@ class DefaultConfig(object):
     # Get the app root path
     # Get the app root path
     #            <_basedir>
     #            <_basedir>
     # ../../ -->  flaskbb/flaskbb/configs/base.py
     # ../../ -->  flaskbb/flaskbb/configs/base.py
-    _basedir = os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(
-                            os.path.dirname(__file__)))))
+    basedir = os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(
+                           os.path.dirname(__file__)))))
 
 
     # Python version
     # Python version
-    _version_str = '{0.major}{0.minor}'.format(sys.version_info)
+    py_version = '{0.major}{0.minor}'.format(sys.version_info)
 
 
     # Flask Settings
     # Flask Settings
     # ------------------------------
     # ------------------------------
@@ -61,7 +61,7 @@ class DefaultConfig(object):
     # For PostgresSQL:
     # For PostgresSQL:
     #SQLALCHEMY_DATABASE_URI = "postgresql://flaskbb@localhost:5432/flaskbb"
     #SQLALCHEMY_DATABASE_URI = "postgresql://flaskbb@localhost:5432/flaskbb"
     # For SQLite:
     # For SQLite:
-    SQLALCHEMY_DATABASE_URI = 'sqlite:///' + _basedir + '/' + \
+    SQLALCHEMY_DATABASE_URI = 'sqlite:///' + basedir + '/' + \
                               'flaskbb.sqlite'
                               'flaskbb.sqlite'
 
 
     # This option will be removed as soon as Flask-SQLAlchemy removes it.
     # This option will be removed as soon as Flask-SQLAlchemy removes it.
@@ -85,7 +85,7 @@ class DefaultConfig(object):
     # Full-Text-Search
     # Full-Text-Search
     # ------------------------------
     # ------------------------------
     # This will use the "whoosh_index" directory to store the search indexes
     # This will use the "whoosh_index" directory to store the search indexes
-    WHOOSHEE_DIR = os.path.join(_basedir, "whoosh_index", _version_str)
+    WHOOSHEE_DIR = os.path.join(basedir, "whoosh_index", py_version)
     # How long should whooshee try to acquire write lock? (defaults to 2)
     # How long should whooshee try to acquire write lock? (defaults to 2)
     WHOOSHEE_WRITER_TIMEOUT = 2
     WHOOSHEE_WRITER_TIMEOUT = 2
     # Minimum number of characters for the search (defaults to 3)
     # Minimum number of characters for the search (defaults to 3)
@@ -172,7 +172,7 @@ class DefaultConfig(object):
     # Celery
     # Celery
     CELERY_BROKER_URL = 'redis://localhost:6379'
     CELERY_BROKER_URL = 'redis://localhost:6379'
     CELERY_RESULT_BACKEND = 'redis://localhost:6379'
     CELERY_RESULT_BACKEND = 'redis://localhost:6379'
-    if not REDIS_ENABLED: CELERY_ALWAYS_EAGER=True
+    if not REDIS_ENABLED: CELERY_ALWAYS_EAGER = True
 
 
     # FlaskBB Settings
     # FlaskBB Settings
     # ------------------------------ #
     # ------------------------------ #
@@ -183,4 +183,4 @@ class DefaultConfig(object):
     AUTH_URL_PREFIX = "/auth"
     AUTH_URL_PREFIX = "/auth"
     ADMIN_URL_PREFIX = "/admin"
     ADMIN_URL_PREFIX = "/admin"
     # Plugin Folder
     # Plugin Folder
-    PLUGINS_FOLDER = os.path.join(_basedir, "flaskbb", "plugins")
+    PLUGINS_FOLDER = os.path.join(basedir, "flaskbb", "plugins")

+ 0 - 171
flaskbb/configs/production.py.example

@@ -1,171 +0,0 @@
-"""
-    flaskbb.configs.production
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-    This is how a production configuration can look like.
-
-    :copyright: (c) 2014 by the FlaskBB Team.
-    :license: BSD, see LICENSE for more details.
-"""
-import os
-import datetime
-from flaskbb.configs.default import DefaultConfig
-
-
-class ProductionConfig(DefaultConfig):
-    # Flask Settings
-    # ------------------------------
-    # There is a whole bunch of more settings available here:
-    # http://flask.pocoo.org/docs/0.11/config/#builtin-configuration-values
-    DEBUG = False
-    TESTING = False
-
-    # Server Name - REQUIRED for Celery/Mailing
-    # The name and port number of the server.
-    # Required for subdomain support (e.g.: 'myapp.dev:5000') and
-    # URL generation without a request context but with an application context
-    # which we need in order to generate URLs (with the celery application)
-    # Note that localhost does not support subdomains so setting this to
-    # “localhost” does not help.
-    # Example for the FlaskBB forums: SERVER_NAME = "forums.flaskbb.org"
-    SERVER_NAME =
-
-    # Prefer HTTPS over HTTP
-    PREFERRED_URL_SCHEME = "https"
-
-    # If SEND_LOGS is set to True, the admins (see the mail configuration) will
-    # recieve the error logs per email.
-    SEND_LOGS = False
-
-    # The filename for the info and error logs. The logfiles are stored at
-    # flaskbb/logs
-    INFO_LOG = "info.log"
-    ERROR_LOG = "error.log"
-
-    # Database
-    # ------------------------------
-    # For PostgresSQL:
-    #SQLALCHEMY_DATABASE_URI = "postgresql://flaskbb@localhost:5432/flaskbb"
-    # For SQLite:
-    SQLALCHEMY_DATABASE_URI = 'sqlite:///' + DefaultConfig._basedir + '/' + \
-                              'flaskbb.sqlite'
-
-    # This option will be removed as soon as Flask-SQLAlchemy removes it.
-    # At the moment it is just used to suppress the super annoying warning
-    SQLALCHEMY_TRACK_MODIFICATIONS = False
-    # This will print all SQL statements
-    SQLALCHEMY_ECHO = False
-
-    # Security - IMPORTANT
-    # ------------------------------
-    # This is the secret key that is used for session signing.
-    # You can generate a secure key with os.urandom(24)
-    SECRET_KEY = 'secret key'
-
-    # You can generate the WTF_CSRF_SECRET_KEY the same way as you have
-    # generated the SECRET_KEY. If no WTF_CSRF_SECRET_KEY is provided, it will
-    # use the SECRET_KEY.
-    WTF_CSRF_ENABLED = True
-    WTF_CSRF_SECRET_KEY = "reallyhardtoguess"
-
-
-    # Full-Text-Search
-    # ------------------------------
-    # This will use the "whoosh_index" directory to store the search indexes
-    WHOOSHEE_DIR = os.path.join(DefaultConfig._basedir, "whoosh_index", DefaultConfig._version_str)
-    # How long should whooshee try to acquire write lock? (defaults to 2)
-    WHOOSHEE_WRITER_TIMEOUT = 2
-    # Minimum number of characters for the search (defaults to 3)
-    WHOOSHEE_MIN_STRING_LEN = 3
-
-    # Auth
-    # ------------------------------
-    LOGIN_VIEW = "auth.login"
-    REAUTH_VIEW = "auth.reauth"
-    LOGIN_MESSAGE_CATEGORY = "info"
-    REFRESH_MESSAGE_CATEGORY = "info"
-
-    # The name of the cookie to store the “remember me” information in.
-    REMEMBER_COOKIE_NAME = "remember_token"
-    # The amount of time before the cookie expires, as a datetime.timedelta object.
-    # Default: 365 days (1 non-leap Gregorian year)
-    REMEMBER_COOKIE_DURATION = datetime.timedelta(days=365)
-    # If the “Remember Me” cookie should cross domains,
-    # set the domain value here (i.e. .example.com would allow the cookie
-    # to be used on all subdomains of example.com).
-    REMEMBER_COOKIE_DOMAIN = None
-    # Limits the “Remember Me” cookie to a certain path.
-    REMEMBER_COOKIE_PATH = "/"
-    # Restricts the “Remember Me” cookie’s scope to secure channels (typically HTTPS).
-    REMEMBER_COOKIE_SECURE = None
-    # Prevents the “Remember Me” cookie from being accessed by client-side scripts.
-    REMEMBER_COOKIE_HTTPONLY = False
-
-    # Rate Limiting via Flask-Limiter
-    # -------------------------------
-    # A full list with configuration values is available at the flask-limiter
-    # docs, but you actually just need those settings below.
-    # You can disabled the Rate Limiter here as well - it will overwrite
-    # the setting from the admin panel!
-    # RATELIMIT_ENABLED = True
-    # You can choose from:
-    #   memory:// (default)
-    #   redis://host:port
-    #   memcached://host:port
-    # Using the redis storage requires the installation of the redis package,
-    # which will be installed if you enable REDIS_ENABLE while memcached
-    # relies on the pymemcache package.
-    #RATELIMIT_STORAGE_URL = "redis://localhost:6379"
-
-    # Caching
-    # ------------------------------
-    # For all available caching types, have a look at the Flask-Cache docs
-    # https://pythonhosted.org/Flask-Caching/#configuring-flask-caching
-    CACHE_TYPE = "simple"
-    # For redis:
-    #CACHE_TYPE = "redis"
-    CACHE_DEFAULT_TIMEOUT = 60
-
-    # Mail
-    # ------------------------------
-    # Google Mail Example
-    #MAIL_SERVER = "smtp.gmail.com"
-    #MAIL_PORT = 465
-    #MAIL_USE_SSL = True
-    #MAIL_USERNAME = "your_username@gmail.com"
-    #MAIL_PASSWORD = "your_password"
-    #MAIL_DEFAULT_SENDER = ("Your Name", "your_username@gmail.com")
-
-    # Local SMTP Server
-    MAIL_SERVER = "localhost"
-    MAIL_PORT = 25
-    MAIL_USE_SSL = False
-    MAIL_USE_TLS = False
-    MAIL_USERNAME = "noreply@example.org"
-    MAIL_PASSWORD = ""
-    MAIL_DEFAULT_SENDER = ("Default Sender", "noreply@example.org")
-    # Where to logger should send the emails to
-    ADMINS = ["admin@example.org"]
-
-    # Redis
-    # ------------------------------ #
-    # If redis is enabled, it can be used for:
-    #   - Sending non blocking emails via Celery (Task Queue)
-    #   - Caching
-    #   - Rate Limiting
-    REDIS_ENABLED = False
-    REDIS_URL = "redis://localhost:6379"  # or with a password: "redis://:password@localhost:6379"
-    REDIS_DATABASE = 0
-
-    # Celery
-    CELERY_BROKER_URL = 'redis://localhost:6379'
-    CELERY_RESULT_BACKEND = 'redis://localhost:6379'
-
-    # FlaskBB Settings
-    # ------------------------------ #
-    # URL Prefixes
-    FORUM_URL_PREFIX = ""
-    USER_URL_PREFIX = "/user"
-    MESSAGE_URL_PREFIX = "/message"
-    AUTH_URL_PREFIX = "/auth"
-    ADMIN_URL_PREFIX = "/admin"