default.py 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. # -*- coding: utf-8 -*-
  2. """
  3. flaskbb.configs.default
  4. ~~~~~~~~~~~~~~~~~~~~~~~
  5. This is the default configuration for FlaskBB that every site should have.
  6. You can override these configuration variables in another class.
  7. :copyright: (c) 2014 by the FlaskBB Team.
  8. :license: BSD, see LICENSE for more details.
  9. """
  10. import os
  11. import sys
  12. import datetime
  13. import glob
  14. from flaskbb.utils.helpers import get_alembic_branches
  15. class DefaultConfig(object):
  16. # Get the app root path
  17. # <_basedir>
  18. # ../../ --> flaskbb/flaskbb/configs/base.py
  19. basedir = os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(
  20. os.path.dirname(__file__)))))
  21. # Python version
  22. py_version = '{0.major}{0.minor}'.format(sys.version_info)
  23. # Flask Settings
  24. # ------------------------------
  25. # There is a whole bunch of more settings available here:
  26. # http://flask.pocoo.org/docs/0.11/config/#builtin-configuration-values
  27. DEBUG = False
  28. TESTING = False
  29. # Server Name
  30. # The name and port number of the server.
  31. # Required for subdomain support (e.g.: 'myapp.dev:5000') and
  32. # URL generation without a request context but with an application context
  33. # which we need in order to generate URLs (with the celery application)
  34. # Note that localhost does not support subdomains so setting this to
  35. # “localhost” does not help.
  36. # Example for the FlaskBB forums: SERVER_NAME = "forums.flaskbb.org"
  37. #SERVER_NAME =
  38. # The preferred url scheme. In a productive environment it is highly
  39. # recommended to use 'https'.
  40. # This only affects the url generation with 'url_for'.
  41. PREFERRED_URL_SCHEME = "http"
  42. # If SEND_LOGS is set to True, the admins (see the mail configuration) will
  43. # recieve the error logs per email.
  44. SEND_LOGS = False
  45. # The filename for the info and error logs. The logfiles are stored at
  46. # flaskbb/logs
  47. INFO_LOG = "info.log"
  48. ERROR_LOG = "error.log"
  49. # Database
  50. # ------------------------------
  51. # For PostgresSQL:
  52. #SQLALCHEMY_DATABASE_URI = "postgresql://flaskbb@localhost:5432/flaskbb"
  53. # For SQLite:
  54. SQLALCHEMY_DATABASE_URI = 'sqlite:///' + basedir + '/' + \
  55. 'flaskbb.sqlite'
  56. # This option will be removed as soon as Flask-SQLAlchemy removes it.
  57. # At the moment it is just used to suppress the super annoying warning
  58. SQLALCHEMY_TRACK_MODIFICATIONS = False
  59. # This will print all SQL statements
  60. SQLALCHEMY_ECHO = False
  61. ALEMBIC = {
  62. 'script_location': os.path.join(basedir, "migrations"),
  63. 'version_locations': get_alembic_branches()
  64. }
  65. ALEMBIC_CONTEXT = {
  66. 'render_as_batch': True
  67. }
  68. # Security
  69. # ------------------------------
  70. # This is the secret key that is used for session signing.
  71. # You can generate a secure key with os.urandom(24)
  72. SECRET_KEY = 'secret key'
  73. # You can generate the WTF_CSRF_SECRET_KEY the same way as you have
  74. # generated the SECRET_KEY. If no WTF_CSRF_SECRET_KEY is provided, it will
  75. # use the SECRET_KEY.
  76. WTF_CSRF_ENABLED = True
  77. WTF_CSRF_SECRET_KEY = "reallyhardtoguess"
  78. # Full-Text-Search
  79. # ------------------------------
  80. # This will use the "whoosh_index" directory to store the search indexes
  81. WHOOSHEE_DIR = os.path.join(basedir, "whoosh_index", py_version)
  82. # How long should whooshee try to acquire write lock? (defaults to 2)
  83. WHOOSHEE_WRITER_TIMEOUT = 2
  84. # Minimum number of characters for the search (defaults to 3)
  85. WHOOSHEE_MIN_STRING_LEN = 3
  86. # Auth
  87. # ------------------------------
  88. LOGIN_VIEW = "auth.login"
  89. REAUTH_VIEW = "auth.reauth"
  90. LOGIN_MESSAGE_CATEGORY = "info"
  91. REFRESH_MESSAGE_CATEGORY = "info"
  92. # The name of the cookie to store the “remember me” information in.
  93. REMEMBER_COOKIE_NAME = "remember_token"
  94. # The amount of time before the cookie expires, as a datetime.timedelta object.
  95. REMEMBER_COOKIE_DURATION = datetime.timedelta(days=365)
  96. # If the “Remember Me” cookie should cross domains,
  97. # set the domain value here (i.e. .example.com would allow the cookie
  98. # to be used on all subdomains of example.com).
  99. REMEMBER_COOKIE_DOMAIN = None
  100. # Limits the “Remember Me” cookie to a certain path.
  101. REMEMBER_COOKIE_PATH = "/"
  102. # Restricts the “Remember Me” cookie’s scope to secure channels (typically HTTPS).
  103. REMEMBER_COOKIE_SECURE = None
  104. # Prevents the “Remember Me” cookie from being accessed by client-side scripts.
  105. REMEMBER_COOKIE_HTTPONLY = False
  106. # Rate Limiting via Flask-Limiter
  107. # -------------------------------
  108. # A full list with configuration values is available at the flask-limiter
  109. # docs, but you actually just need those settings below.
  110. # You can disabled the Rate Limiter here as well - it will overwrite
  111. # the setting from the admin panel!
  112. # RATELIMIT_ENABLED = True
  113. # You can choose from:
  114. # memory:// (default)
  115. # redis://host:port
  116. # memcached://host:port
  117. # Using the redis storage requires the installation of the redis package,
  118. # which will be installed if you enable REDIS_ENABLE while memcached
  119. # relies on the pymemcache package.
  120. #RATELIMIT_STORAGE_URL = "redis://localhost:6379"
  121. # Caching
  122. # ------------------------------
  123. # For all available caching types, have a look at the Flask-Cache docs
  124. # https://pythonhosted.org/Flask-Caching/#configuring-flask-caching
  125. CACHE_TYPE = "simple"
  126. # For redis:
  127. #CACHE_TYPE = "redis"
  128. CACHE_DEFAULT_TIMEOUT = 60
  129. # Mail
  130. # ------------------------------
  131. # Google Mail Example
  132. #MAIL_SERVER = "smtp.gmail.com"
  133. #MAIL_PORT = 465
  134. #MAIL_USE_SSL = True
  135. #MAIL_USERNAME = "your_username@gmail.com"
  136. #MAIL_PASSWORD = "your_password"
  137. #MAIL_DEFAULT_SENDER = ("Your Name", "your_username@gmail.com")
  138. # Local SMTP Server
  139. MAIL_SERVER = "localhost"
  140. MAIL_PORT = 25
  141. MAIL_USE_SSL = False
  142. MAIL_USE_TLS = False
  143. MAIL_USERNAME = "noreply@example.org"
  144. MAIL_PASSWORD = ""
  145. MAIL_DEFAULT_SENDER = ("Default Sender", "noreply@example.org")
  146. # Where to logger should send the emails to
  147. ADMINS = ["admin@example.org"]
  148. # Redis
  149. # ------------------------------ #
  150. # If redis is enabled, it can be used for:
  151. # - Sending non blocking emails via Celery (Task Queue)
  152. # - Caching
  153. # - Rate Limiting
  154. REDIS_ENABLED = False
  155. REDIS_URL = "redis://localhost:6379" # or with a password: "redis://:password@localhost:6379"
  156. REDIS_DATABASE = 0
  157. # Celery
  158. CELERY_BROKER_URL = 'redis://localhost:6379'
  159. CELERY_RESULT_BACKEND = 'redis://localhost:6379'
  160. if not REDIS_ENABLED: CELERY_ALWAYS_EAGER = True
  161. # FlaskBB Settings
  162. # ------------------------------ #
  163. # URL Prefixes
  164. FORUM_URL_PREFIX = ""
  165. USER_URL_PREFIX = "/user"
  166. MESSAGE_URL_PREFIX = "/message"
  167. AUTH_URL_PREFIX = "/auth"
  168. ADMIN_URL_PREFIX = "/admin"
  169. # Plugin Folder
  170. PLUGINS_FOLDER = os.path.join(basedir, "flaskbb", "plugins")