settings sanity check
Does mailman-web do sanity checks in settings.py?
Suppose I have the following:
Q_CLUSTER = { 'name': 'mailman3-web', 'workers': 8, 'retry': 360, 'timeout': 300, 'save_limit': 100, 'orm': 'default', }
Q_CLUSTER = { 'retry': 320, 'timeout': 300, 'save_limit': 100, 'orm': 'default', }
Which setting will it go with?
And why doesn't it complain about a setting being made 2x?
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-)
On 2023-02-08 10:50:20 +0300 (+0300), Odhiambo Washington wrote:
Does mailman-web do sanity checks in settings.py?
Not that I've seen, other than a traceback if the Python interpreter can't parse it at least.
Suppose I have the following:
Q_CLUSTER = { [...] Q_CLUSTER = { [...] Which setting will it go with?
The second one.
And why doesn't it complain about a setting being made 2x?
It's a Python script, and Python allows you to redefine variables (as do basically all scripting languages for that matter).
Jeremy Stanley
[mostly ninja'd by Jeremy, but I 'd already typed this, and you might find PyCharm a useful editor.]
I'm not a Django expert, but from https://docs.djangoproject.com/en/4.1/topics/settings/ it sounds like they just import the settings.py as a module. This means it is run by the python language itself as a python program. It's not merely a data file describing the settings -- it's code that is run as a program. The name Q_CLUSTER refers to a variable and the = operator assigns the value on its right hand side to that variable/name on the left. (The curly braces enclose an object literal: a comma-separated list of name: value pairs.)
So, it will go with the second set of properties for Q_CLUSTER. There is no error; it's perfectly okay to store one value to the name/variable Q_CLUSTER and then later in your program assign a different value to the same name/variable. The code runs from top to bottom, so the second value assigned to Q_CLUSTER is what remains in memory after these settings have been processed.
If you would like a tool that *would* complain, take a look at PyCharm Community Edition (no cost... not sure it's free-libre, though) from JetBrains: https://www.jetbrains.com/pycharm/download/#section=windows
When I paste your snippet into an PyCharm editor window, it puts a warning highlight behind the second instance of Q_CLUSTER. When I hover over that, a pop-up tooltip cautions that I "Redeclared 'Q_CLUSTER' defined above without usage' and I can click on it for an extended explanation.
(It also caught that you have three spaces before 'retry' and then four before 'timeout'... in some places in python syntax, inconsistent indentation is an error, but not here)
Hope that's helpful.
David Brown, IT Specialist dave@aasv.org
This message contains confidential information belonging to the American Association of Swine Veterinarians (AASV) and is intended only for the individual(s) named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by email if you have received this e-mail by mistake and delete this e-mail from your system. Any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the AASV.
-----Original Message----- From: Odhiambo Washington <odhiambo@gmail.com> Sent: Wednesday, February 8, 2023 2:50 AM To: Mailman users <mailman-users@mailman3.org> Subject: [MM3-users] settings sanity check
Does mailman-web do sanity checks in settings.py?
Suppose I have the following:
Q_CLUSTER = { 'name': 'mailman3-web', 'workers': 8, 'retry': 360, 'timeout': 300, 'save_limit': 100, 'orm': 'default', }
Q_CLUSTER = { 'retry': 320, 'timeout': 300, 'save_limit': 100, 'orm': 'default', }
Which setting will it go with?
And why doesn't it complain about a setting being made 2x?
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-) _______________________________________________ Mailman-users mailing list -- mailman-users@mailman3.org To unsubscribe send an email to mailman-users-leave@mailman3.org https://lists.mailman3.org/mailman3/lists/mailman-users.mailman3.org/ Archived at: https://lists.mailman3.org/archives/list/mailman-users@mailman3.org/message/...
This message sent to dave@aasv.org
participants (3)
-
David Brown
-
Jeremy Stanley
-
Odhiambo Washington