Subject: [PATCH] pglister: Add possibility to override settings.py in settings_local.py

From: Célestin Matte <[email-masked]>
Date: Wed, 27 Oct 2021 17:02:15 +0200

Following the model of pgweb and pgarchives

-- 
Célestin Matte

From c1c08dca0117724a78a642f44ec64a2cc9e9e78c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9lestin=20Matte?= <[email-masked]>
Date: Wed, 27 Oct 2021 16:58:05 +0200
Subject: [PATCH] Add possibility to override settings.py in settings_local.py

Following the model of pgweb and pgarchives
---
 .gitignore               | 1 +
 setup.cfg                | 2 +-
 web/pglister/settings.py | 3 +++
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 8e29657..788789f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
 *.pyc
 /pglister.ini
 .idea
+web/pglister/settings_local.py
diff --git a/setup.cfg b/setup.cfg
index af55e73..af3c0c8 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
 [pycodestyle]
 statistics=True
 ignore=E402,E501,E741,W504
-exclude=web/dep,web/pglister/auth.py
+exclude=web/dep,web/pglister/auth.py,web/pglister/settings_local.py
 max-line-length=120
diff --git a/web/pglister/settings.py b/web/pglister/settings.py
index ba69207..efa34ea 100644
--- a/web/pglister/settings.py
+++ b/web/pglister/settings.py
@@ -149,3 +149,6 @@ if EXIM_INTEGRATION:
 if DEBUG and DEBUG_TOOLBAR:
     MIDDLEWARE.append('debug_toolbar.middleware.DebugToolbarMiddleware')
     INSTALLED_APPS.append('debug_toolbar')
+
+# Load local settings overrides
+from .settings_local import *
-- 
2.33.1

---

From: Magnus Hagander <[email-masked]>
Date: Sun, 31 Oct 2021 15:27:29 +0000

> Following the model of pgweb and pgarchives

Hi!

local_settings.py is already ignored in web/pglister/.gitignore -- does
that not work for some reason? It works fine from here.

Second, I'm not sure why we want to exclude local_settings.py from
pycodestyle in general?

And finally, settings.py already contains:
try:
    from .local_settings import *
except ImportError:
    pass

Just a couple of lines above where you are adding it back again. Is that
also for some reason not working?

And it is important that it is included before we do the exim part for
example -- otherwise you cannot control that from within local_settings.py.

-- 
 Magnus Hagander
 Me: https://www.hagander.net/ <http://www.hagander.net/>
 Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>

---

From: Célestin Matte <[email-masked]>
Date: Sun, 31 Oct 2021 19:02:46 +0100

Hello,

> Just a couple of lines above where you are adding it back again. Is that also for some reason not working?

Right, I missed that. It's just that in pgweb and pgarchives, the file is called settings_local.py, whereas pglister calls it local_settings.py. This is just a question of naming consistency, then. Do you think it's worth patching?

> Second, I'm not sure why we want to exclude local_settings.py from pycodestyle in general?

It's ignored in pgweb, I just assumed there was a good reason for that and did the same thing for consistency.

Cheers,
-- 
Célestin Matte

---

From: Magnus Hagander <[email-masked]>
Date: Thu, 4 Nov 2021 11:24:25 +0100

On Sun, Oct 31, 2021 at 7:02 PM Célestin Matte <[email-masked]>
wrote:

> Right, I missed that. It's just that in pgweb and pgarchives, the file is
> called settings_local.py, whereas pglister calls it local_settings.py. This
> is just a question of naming consistency, then. Do you think it's worth
> patching?
>

If anything, we'd want to move to local_settings.py in that case -- the
reason we switched to doing that in a bunch of the other projects is TBH
something as simple as "then tab completion works better".

In general we've said it's not worth breaking compat for it on the old
repos though. That can obviously be argued. But if we do, we definitely
don't want to do *both*, in that case we should remove them.

> did the same thing for consistency.

Oh, I wasn't even aware of that. TBH, I'm not sure that's intentional, that
may be a leak from "it was easiest to do that in the beginning".

I don't really see a reason why we wouldn't want that file to be scanned as
well -- do you?

---

From: Célestin Matte <[email-masked]>
Date: Thu, 4 Nov 2021 16:22:06 +0100

> If anything, we'd want to move to local_settings.py in that case -- the reason we switched to doing that in a bunch of the other projects is TBH something as simple as "then tab completion works better".
> 
> In general we've said it's not worth breaking compat for it on the old repos though. That can obviously be argued. But if we do, we definitely don't want to do *both*, in that case we should remove them.

Hrm, so what's your decision on this?

> I don't really see a reason why we wouldn't want that file to be scanned as well -- do you? 

I guess there is no real point scanning a file for proper style if it's not going to get committed

-- 
Célestin Matte