From 4a5ad32040d2834a585c6fbbdd5b5fb33a656c15 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Thu, 25 Apr 2024 17:59:54 -0700 Subject: [PATCH] add django-requests-tracker --- archivebox/core/settings.py | 11 +++++++++++ archivebox/core/urls.py | 8 ++++---- pdm.lock | 2 +- pyproject.toml | 12 +++++++----- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/archivebox/core/settings.py b/archivebox/core/settings.py index c9cd944e..923ae62c 100644 --- a/archivebox/core/settings.py +++ b/archivebox/core/settings.py @@ -173,6 +173,17 @@ if DEBUG_TOOLBAR: ] MIDDLEWARE = [*MIDDLEWARE, 'debug_toolbar.middleware.DebugToolbarMiddleware'] + +# https://github.com/bensi94/Django-Requests-Tracker (improved version of django-debug-toolbar) +# Must delete archivebox/templates/admin to use because it relies on some things we override +# visit /__requests_tracker__/ to access +DEBUG_REQUESTS_TRACKER = False +if DEBUG_REQUESTS_TRACKER: + INSTALLED_APPS += ["requests_tracker"] + MIDDLEWARE += ["requests_tracker.middleware.requests_tracker_middleware"] + INTERNAL_IPS = ["127.0.0.1", "10.0.2.2", "0.0.0.0", "*"] + + ################################################################################ ### Staticfile and Template Settings ################################################################################ diff --git a/archivebox/core/urls.py b/archivebox/core/urls.py index 0526633c..14b3d774 100644 --- a/archivebox/core/urls.py +++ b/archivebox/core/urls.py @@ -52,10 +52,10 @@ urlpatterns = [ urlpatterns += staticfiles_urlpatterns() if settings.DEBUG_TOOLBAR: - import debug_toolbar - urlpatterns += [ - path('__debug__/', include(debug_toolbar.urls)), - ] + urlpatterns += [path('__debug__/', include("debug_toolbar.urls"))] + +if settings.DEBUG_REQUESTS_TRACKER: + urlpatterns += [path("__requests_tracker__/", include("requests_tracker.urls"))] # # Proposed FUTURE URLs spec diff --git a/pdm.lock b/pdm.lock index 80cf49ee..7e8a1fc1 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "ldap", "sonic"] strategy = ["cross_platform", "inherit_metadata"] lock_version = "4.4.1" -content_hash = "sha256:680d048f6c24c4b822829a9a4bd5d4ce235bfde2f8c58fd531cd434e4cf3ee13" +content_hash = "sha256:0d6b1cd72f1893512e04c3b47f81666243bd4f91afe46fabc15b303284a3cc74" [[package]] name = "annotated-types" diff --git a/pyproject.toml b/pyproject.toml index 057f4f35..b1008449 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -109,6 +109,7 @@ debug = [ "django-debug-toolbar", "djdt_flamegraph", "ipdb", + "requests-tracker>=0.3.3", ] test = [ "pytest", @@ -119,6 +120,12 @@ lint = [ "django-stubs", ] +[tool.pdm.scripts] +lint = "./bin/lint.sh" +test = "./bin/test.sh" +# all = {composite = ["lint mypackage/", "test -v tests/"]} + + [build-system] requires = ["pdm-backend"] build-backend = "pdm.backend" @@ -127,11 +134,6 @@ build-backend = "pdm.backend" archivebox = "archivebox.cli:main" -[tool.pdm.scripts] -lint = "./bin/lint.sh" -test = "./bin/test.sh" -# all = {composite = ["lint mypackage/", "test -v tests/"]} - [tool.pytest.ini_options] testpaths = [ "tests" ]