Skip to content
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

add option to use django-request for detailed logging of all requests #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

megies
Copy link
Collaborator

@megies megies commented Sep 22, 2017

This adds a ways of adding additional apps and middleware through local_settings.py, also being able to control position of additional middleware in the chain.

django-request is commented by default, so deactivated but can be switched on in local_settings.py.

Tested it locally, works when activated before initial jane setup (before intial migrations).

Closes #41

@krischer
Copy link
Owner

This seems fairly complicated especially as it pushes quite some logic to the settings.py but I also don't see another obvious option of how to do this. Maybe have settings.py call a callback function from local_settings.py with all locals() variables that the local_settings.py could then modify as it sees fit?

@barsch Any opinions/advice how this is usually handled with django?

Otherwise I'd be fine with this.

@barsch
Copy link
Collaborator

barsch commented Sep 27, 2017

@megies
Copy link
Collaborator Author

megies commented Sep 27, 2017

Different approach, not sure if it's less ugly. I don't care which way.

commented, so deactivated by default but can be switched on in
local_settings.py

Tested it locally, works when activated before initial jane setup
(migrations)
@megies megies force-pushed the additional_apps_in_local_settings branch from 814f10b to 401b366 Compare September 28, 2017 12:41
@codecov-io
Copy link

Codecov Report

Merging #44 into master will decrease coverage by 0.26%.
The diff coverage is 20%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #44      +/-   ##
==========================================
- Coverage   85.65%   85.38%   -0.27%     
==========================================
  Files          56       56              
  Lines        3652     3667      +15     
==========================================
+ Hits         3128     3131       +3     
- Misses        524      536      +12
Impacted Files Coverage Δ
src/jane/settings.py 72.28% <20%> (-11.54%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4178fd3...401b366. Read the comment docs.

@megies
Copy link
Collaborator Author

megies commented Sep 28, 2017

So, any objections to merging this @krischer?

@krischer
Copy link
Owner

I kind of like the solution in the second comment of @barch s link: In local_settings.py do:

def get_setting(setting):
    import settings
    return getattr(settings, setting)

INSTALLED_APPS = get_setting('INSTALLED_APPS') + ('debug_toolbar', )
MIDDLEWARE_CLASSES = get_setting('MIDDLEWARE_CLASSES') + ('debug_toolbar.middleware.DebugToolbarMiddleware',)
INTERNAL_IPS = ('127.0.0.1',)

This would remove any complexity in the default settings.py and push it completely to the user. Also the local_settings.py with your solution has to contain two additional variables.

I'm not fully convinced this approach does not result in circular imports but if it works as advertised it might be a nice alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants