From aec07a1cb59ec25765cc2f5c4b6011bccb989abc Mon Sep 17 00:00:00 2001 From: Leonardo Giordani Date: Sun, 21 Jun 2020 09:29:45 +0100 Subject: [PATCH 1/4] Removed misleading DEBUG variable from examples --- docs/config.rst | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index 891c299f..f02702b2 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -429,7 +429,6 @@ sure to use uppercase letters for your config keys. Here is an example of a configuration file:: # Example configuration - DEBUG = False SECRET_KEY = b'_5#y2L"F4Q8z\n\xec]/' Make sure to load the configuration very early on, so that extensions have @@ -554,7 +553,6 @@ An interesting pattern is also to use classes and inheritance for configuration:: class Config(object): - DEBUG = False TESTING = False DATABASE_URI = 'sqlite:///:memory:' @@ -562,7 +560,7 @@ configuration:: DATABASE_URI = 'mysql://user@localhost/foo' class DevelopmentConfig(Config): - DEBUG = True + pass class TestingConfig(Config): TESTING = True @@ -589,7 +587,6 @@ your configuration classes:: class Config(object): """Base config, uses staging database server.""" - DEBUG = False TESTING = False DB_SERVER = '192.168.1.56' @@ -603,11 +600,9 @@ your configuration classes:: class DevelopmentConfig(Config): DB_SERVER = 'localhost' - DEBUG = True class TestingConfig(Config): DB_SERVER = 'localhost' - DEBUG = True DATABASE_URI = 'sqlite:///:memory:' There are many different ways and it's up to you how you want to manage From efbd721f20cbe21ae5350380035752282882e9a2 Mon Sep 17 00:00:00 2001 From: Leonardo Giordani Date: Tue, 23 Jun 2020 14:56:51 +0100 Subject: [PATCH 2/4] Changed example DATABASE_URI values --- docs/config.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index f02702b2..f1f35be3 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -552,17 +552,21 @@ and import different hard-coded files based on that. An interesting pattern is also to use classes and inheritance for configuration:: + import os + + basedir = os.path.abspath(os.path.dirname(__file__)) + class Config(object): TESTING = False - DATABASE_URI = 'sqlite:///:memory:' class ProductionConfig(Config): DATABASE_URI = 'mysql://user@localhost/foo' class DevelopmentConfig(Config): - pass + DATABASE_URI = "sqlite:///" + os.path.join(basedir, "foo.db") class TestingConfig(Config): + DATABASE_URI = 'sqlite:///:memory:' TESTING = True To enable such a config you just have to call into From 26ec470afbfb8b643f1d0ba3501b4def42b58911 Mon Sep 17 00:00:00 2001 From: Leonardo Giordani Date: Tue, 23 Jun 2020 15:06:37 +0100 Subject: [PATCH 3/4] Fixed trailing whitespace --- docs/config.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config.rst b/docs/config.rst index f1f35be3..7a28e027 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -555,7 +555,7 @@ configuration:: import os basedir = os.path.abspath(os.path.dirname(__file__)) - + class Config(object): TESTING = False From 2254adf8455953019cadd54ba837c53d3dfaca5d Mon Sep 17 00:00:00 2001 From: Leonardo Giordani Date: Tue, 23 Jun 2020 15:14:03 +0100 Subject: [PATCH 4/4] Simplified version of file-based database --- docs/config.rst | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index 7a28e027..f09518d4 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -552,10 +552,6 @@ and import different hard-coded files based on that. An interesting pattern is also to use classes and inheritance for configuration:: - import os - - basedir = os.path.abspath(os.path.dirname(__file__)) - class Config(object): TESTING = False @@ -563,7 +559,7 @@ configuration:: DATABASE_URI = 'mysql://user@localhost/foo' class DevelopmentConfig(Config): - DATABASE_URI = "sqlite:///" + os.path.join(basedir, "foo.db") + DATABASE_URI = "sqlite:////tmp/foo.db" class TestingConfig(Config): DATABASE_URI = 'sqlite:///:memory:'