-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Unify usage of settings and remove the usage of getattr for settings #5588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did a quick review, we need to check more closely to some default values.
readthedocs/settings/base.py
Outdated
@@ -42,11 +44,18 @@ class CommunityBaseSettings(Settings): | |||
PUBLIC_DOMAIN = None | |||
PUBLIC_DOMAIN_USES_HTTPS = False | |||
USE_SUBDOMAIN = False | |||
USE_SUBDOMAINS = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already set just above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was a bit confused about this. one is USE_SUBDOMAIN
and the other one is USE_SUBDOMAINS
Which is called here:
https://github.com/rtfd/readthedocs.org/blob/3d36585aca80e7f79b0c5bfeb1e4f6f1e38b8f06/readthedocs/core/context_processors.py#L13
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I just realized of the final s
. We should investigate a liitle more here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stsewd I did some investigation on my own. I found that this settings is only being used by context_processors.py
https://github.com/rtfd/readthedocs.org/blob/7fa9002586b2c5c2fae5c78e5ad736d9d46f7ad4/readthedocs/core/context_processors.py#L13
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this was a typo and the intended usage was USE_SUBDOMAIN
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@humitos I thought that too. Should I Change this to USE_SUBDOMAIN
and Update the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like most of the code and tests we use USE_SUBDOMAIN
, also I search the whole project (and the corporate site), it's safe to rename it in the context processor file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool 💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stsewd Updated the PR
@stsewd Updated the PR with the changes you suggested :) |
) | ||
DOCKER_IMAGE_SETTINGS = getattr(settings, 'DOCKER_IMAGE_SETTINGS', {}) | ||
DOCKER_IMAGE = settings.DOCKER_IMAGE | ||
DOCKER_IMAGE_SETTINGS = settings.DOCKER_IMAGE_SETTINGS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we are re-defining these here instead of using them directly from the settings.
object in the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@humitos I did not change it as it was already like this. And also they are being called in many parts of the config.py
file. should I use them directly from the settings in the places of config.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vote to do that in another PR
I just wanted to chime in that I'm excited for this change. This will simplify a lot of things and centralize all our settings in one place so they are easier to understand! |
@@ -10,7 +10,7 @@ def readthedocs_processor(request): | |||
exports = { | |||
'PUBLIC_DOMAIN': settings.PUBLIC_DOMAIN, | |||
'PRODUCTION_DOMAIN': settings.PRODUCTION_DOMAIN, | |||
'USE_SUBDOMAINS': settings.USE_SUBDOMAINS, | |||
'USE_SUBDOMAINS': settings.USE_SUBDOMAIN, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should rename the key too (I just checked, and there is not other places using this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stsewd Done.:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need to change more code
That should remain as it is. |
@stsewd I might have missed these two from my search. Updated the PR! Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. We should merge this before it generates conflicts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @saadmk11 for your work on this. Changes look good to me.
This PR touches many different files. I'm merging it now to avoid conflicts and also to start testing it locally considering that there are many settings re-defined. Although, the defaults on |
I think we should probably do a followup here to remove places where we're using |
This is fine for now though 👍 |
@ericholscher Okay! I will start working on it:) |
@ericholscher @saadmk11 I already mentioned this at #5588 (comment) I think the new PR should include all the changes for this pattern. |
I wasn't quite sure what to with this so I left it as it is:
https://github.com/rtfd/readthedocs.org/blob/7fa9002586b2c5c2fae5c78e5ad736d9d46f7ad4/readthedocs/core/utils/extend.py#L29
closes #2140