default.py 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. class DefaultConfig(object):
  14. # Get the app root path
  15. # <_basedir>
  16. # ../../ --> flaskbb/flaskbb/configs/base.py
  17. basedir = os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(
  18. os.path.dirname(__file__)))))
  19. # Python version
  20. py_version = '{0.major}{0.minor}'.format(sys.version_info)
  21. # Flask Settings
  22. # ------------------------------
  23. # There is a whole bunch of more settings available here:
  24. # http://flask.pocoo.org/docs/0.11/config/#builtin-configuration-values
  25. DEBUG = False
  26. TESTING = False
  27. # Server Name
  28. # The name and port number of the server.
  29. # Required for subdomain support (e.g.: 'myapp.dev:5000') and
  30. # URL generation without a request context but with an application context
  31. # which we need in order to generate URLs (with the celery application)
  32. # Note that localhost does not support subdomains so setting this to
  33. # “localhost” does not help.
  34. # Example for the FlaskBB forums: SERVER_NAME = "forums.flaskbb.org"
  35. #SERVER_NAME =
  36. # The preferred url scheme. In a productive environment it is highly
  37. # recommended to use 'https'.
  38. # This only affects the url generation with 'url_for'.
  39. PREFERRED_URL_SCHEME = "http"
  40. # Logging Settings
  41. # ------------------------------
  42. # This config section will deal with the logging settings
  43. # for FlaskBB, adjust as needed.
  44. # Logging Config Path
  45. # see https://docs.python.org/library/logging.config.html#logging.config.fileConfig
  46. # for more details. Should either be None or a path to a file
  47. # If this is set to a path, consider setting USE_DEFAULT_LOGGING to False
  48. # otherwise there may be interactions between the log configuration file
  49. # and the default logging setting.
  50. #
  51. # If set to a file path, this should be an absolute file path
  52. LOG_CONF_FILE = None
  53. # Path to store the INFO and ERROR logs
  54. # If None this defaults to flaskbb/logs
  55. #
  56. # If set to a file path, this should be an absolute path
  57. LOG_PATH = os.path.join(basedir, 'logs')
  58. LOG_DEFAULT_CONF = {
  59. 'version': 1,
  60. 'disable_existing_loggers': False,
  61. 'formatters': {
  62. 'standard': {
  63. 'format': '%(asctime)s %(levelname)-7s %(name)-25s %(message)s'
  64. },
  65. 'advanced': {
  66. 'format': '%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'
  67. }
  68. },
  69. 'handlers': {
  70. 'console': {
  71. 'level': 'NOTSET',
  72. 'formatter': 'standard',
  73. 'class': 'logging.StreamHandler',
  74. },
  75. 'flaskbb': {
  76. 'level': 'DEBUG',
  77. 'formatter': 'standard',
  78. 'class': 'logging.handlers.RotatingFileHandler',
  79. 'filename': os.path.join(LOG_PATH, 'flaskbb.log'),
  80. 'mode': 'a',
  81. 'maxBytes': 10485760, # 10MB
  82. 'backupCount': 5,
  83. },
  84. 'infolog': {
  85. 'level': 'INFO',
  86. 'formatter': 'standard',
  87. 'class': 'logging.handlers.RotatingFileHandler',
  88. 'filename': os.path.join(LOG_PATH, 'info.log'),
  89. 'mode': 'a',
  90. 'maxBytes': 10485760, # 10MB
  91. 'backupCount': 5,
  92. },
  93. 'errorlog': {
  94. 'level': 'ERROR',
  95. 'formatter': 'standard',
  96. 'class': 'logging.handlers.RotatingFileHandler',
  97. 'filename': os.path.join(LOG_PATH, 'error.log'),
  98. 'mode': 'a',
  99. 'maxBytes': 10485760, # 10MB
  100. 'backupCount': 5,
  101. }
  102. },
  103. 'loggers': {
  104. 'flask.app': {
  105. 'handlers': ['infolog', 'errorlog'],
  106. 'level': 'INFO',
  107. 'propagate': True
  108. },
  109. 'flaskbb': {
  110. 'handlers': ['console', 'flaskbb'],
  111. 'level': 'WARNING',
  112. 'propagate': True
  113. },
  114. }
  115. }
  116. # When set to True this will enable the default
  117. # FlaskBB logging configuration which uses the settings
  118. # below to determine logging
  119. USE_DEFAULT_LOGGING = True
  120. # If SEND_LOGS is set to True, the admins (see the mail configuration) will
  121. # recieve the error logs per email.
  122. SEND_LOGS = False
  123. # Database
  124. # ------------------------------
  125. # For MySQL:
  126. #SQLALCHEMY_DATABASE_URI="mysql+pymysql://flaskbb:password@localhost:3306/flaskbb"
  127. # For PostgresSQL:
  128. #SQLALCHEMY_DATABASE_URI = "postgresql://flaskbb@localhost:5432/flaskbb"
  129. # For SQLite:
  130. SQLALCHEMY_DATABASE_URI = 'sqlite:///' + basedir + '/' + \
  131. 'flaskbb.sqlite'
  132. # This option will be removed as soon as Flask-SQLAlchemy removes it.
  133. # At the moment it is just used to suppress the super annoying warning
  134. SQLALCHEMY_TRACK_MODIFICATIONS = False
  135. # This will print all SQL statements
  136. SQLALCHEMY_ECHO = False
  137. ALEMBIC = {
  138. 'script_location': os.path.join(basedir, "migrations"),
  139. 'version_locations': '',
  140. 'file_template': '%%(year)d%%(month).2d%%(day).2d%%(hour).2d%%(minute).2d_%%(rev)s_%%(slug)s'
  141. }
  142. ALEMBIC_CONTEXT = {
  143. 'render_as_batch': True
  144. }
  145. # Security
  146. # ------------------------------
  147. # This is the secret key that is used for session signing.
  148. # You can generate a secure key with os.urandom(24)
  149. SECRET_KEY = 'secret key'
  150. # You can generate the WTF_CSRF_SECRET_KEY the same way as you have
  151. # generated the SECRET_KEY. If no WTF_CSRF_SECRET_KEY is provided, it will
  152. # use the SECRET_KEY.
  153. WTF_CSRF_ENABLED = True
  154. WTF_CSRF_SECRET_KEY = "reallyhardtoguess"
  155. # Full-Text-Search
  156. # ------------------------------
  157. # This will use the "whoosh_index" directory to store the search indexes
  158. WHOOSHEE_DIR = os.path.join(basedir, "whoosh_index", py_version)
  159. # How long should whooshee try to acquire write lock? (defaults to 2)
  160. WHOOSHEE_WRITER_TIMEOUT = 2
  161. # Minimum number of characters for the search (defaults to 3)
  162. WHOOSHEE_MIN_STRING_LEN = 3
  163. # Auth
  164. # ------------------------------
  165. LOGIN_VIEW = "auth.login"
  166. REAUTH_VIEW = "auth.reauth"
  167. LOGIN_MESSAGE_CATEGORY = "info"
  168. REFRESH_MESSAGE_CATEGORY = "info"
  169. # The name of the cookie to store the “remember me” information in.
  170. REMEMBER_COOKIE_NAME = "remember_token"
  171. # The amount of time before the cookie expires, as a datetime.timedelta object.
  172. REMEMBER_COOKIE_DURATION = datetime.timedelta(days=365)
  173. # If the “Remember Me” cookie should cross domains,
  174. # set the domain value here (i.e. .example.com would allow the cookie
  175. # to be used on all subdomains of example.com).
  176. REMEMBER_COOKIE_DOMAIN = None
  177. # Limits the “Remember Me” cookie to a certain path.
  178. REMEMBER_COOKIE_PATH = "/"
  179. # Restricts the “Remember Me” cookie’s scope to secure channels (typically HTTPS).
  180. REMEMBER_COOKIE_SECURE = None
  181. # Prevents the “Remember Me” cookie from being accessed by client-side scripts.
  182. REMEMBER_COOKIE_HTTPONLY = False
  183. # Rate Limiting via Flask-Limiter
  184. # -------------------------------
  185. # A full list with configuration values is available at the flask-limiter
  186. # docs, but you actually just need those settings below.
  187. # You can disabled the Rate Limiter here as well - it will overwrite
  188. # the setting from the admin panel!
  189. # RATELIMIT_ENABLED = True
  190. # You can choose from:
  191. # memory:// (default)
  192. # redis://host:port
  193. # memcached://host:port
  194. # Using the redis storage requires the installation of the redis package,
  195. # which will be installed if you enable REDIS_ENABLE while memcached
  196. # relies on the pymemcache package.
  197. #RATELIMIT_STORAGE_URL = "redis://localhost:6379"
  198. # Caching
  199. # ------------------------------
  200. # For all available caching types, have a look at the Flask-Cache docs
  201. # https://pythonhosted.org/Flask-Caching/#configuring-flask-caching
  202. CACHE_TYPE = "simple"
  203. # For redis:
  204. #CACHE_TYPE = "redis"
  205. CACHE_DEFAULT_TIMEOUT = 60
  206. # Mail
  207. # ------------------------------
  208. # Google Mail Example
  209. #MAIL_SERVER = "smtp.gmail.com"
  210. #MAIL_PORT = 465
  211. #MAIL_USE_SSL = True
  212. #MAIL_USERNAME = "your_username@gmail.com"
  213. #MAIL_PASSWORD = "your_password"
  214. #MAIL_DEFAULT_SENDER = ("Your Name", "your_username@gmail.com")
  215. # Local SMTP Server
  216. MAIL_SERVER = "localhost"
  217. MAIL_PORT = 25
  218. MAIL_USE_SSL = False
  219. MAIL_USE_TLS = False
  220. MAIL_USERNAME = "noreply@example.org"
  221. MAIL_PASSWORD = ""
  222. MAIL_DEFAULT_SENDER = ("Default Sender", "noreply@example.org")
  223. # Where to logger should send the emails to
  224. ADMINS = ["admin@example.org"]
  225. # Redis
  226. # ------------------------------ #
  227. # If redis is enabled, it can be used for:
  228. # - Sending non blocking emails via Celery (Task Queue)
  229. # - Caching
  230. # - Rate Limiting
  231. REDIS_ENABLED = False
  232. REDIS_URL = "redis://localhost:6379" # or with a password: "redis://:password@localhost:6379"
  233. REDIS_DATABASE = 0
  234. # Celery
  235. CELERY_BROKER_URL = 'redis://localhost:6379'
  236. CELERY_RESULT_BACKEND = 'redis://localhost:6379'
  237. BROKER_TRANSPORT_OPTIONS = {'max_retries': 1} # necessary as there's no default
  238. # FlaskBB Settings
  239. # ------------------------------ #
  240. # URL Prefixes
  241. FORUM_URL_PREFIX = ""
  242. USER_URL_PREFIX = "/user"
  243. MESSAGE_URL_PREFIX = "/message"
  244. AUTH_URL_PREFIX = "/auth"
  245. ADMIN_URL_PREFIX = "/admin"
  246. # Remove dead plugins - useful if you want to migrate your instance
  247. # somewhere else and forgot to reinstall the plugins.
  248. # If set to `False` it will NOT remove plugins that are NOT installed on
  249. # the filesystem (virtualenv, site-packages).
  250. REMOVE_DEAD_PLUGINS = False