Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-django-requests-debug-toolbar
for openSUSE:Factory checked in at 2024-02-25 14:06:12
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-django-requests-debug-toolbar (Old)
and
/work/SRC/openSUSE:Factory/.python-django-requests-debug-toolbar.new.1770 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-django-requests-debug-toolbar"
Sun Feb 25 14:06:12 2024 rev:3 rq:1150058 version:0.0.7
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-django-requests-debug-toolbar/python-django-requests-debug-toolbar.changes
2023-06-26 18:16:03.206459587 +0200
+++
/work/SRC/openSUSE:Factory/.python-django-requests-debug-toolbar.new.1770/python-django-requests-debug-toolbar.changes
2024-02-25 14:06:25.789574802 +0100
@@ -1,0 +2,9 @@
+Fri Feb 23 23:46:03 UTC 2024 - Georg Pfuetzenreuter
<[email protected]>
+
+- Update to version 0.0.7
+ 0.0.7:
+ * Recognize json-variants in content-type header
+ 0.0.6:
+ * Replace ThreadCollector with ContextVar
+
+-------------------------------------------------------------------
Old:
----
django-requests-debug-toolbar-0.0.5.tar.gz
New:
----
django-requests-debug-toolbar-0.0.7.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-django-requests-debug-toolbar.spec ++++++
--- /var/tmp/diff_new_pack.S8eUVG/_old 2024-02-25 14:06:26.297593191 +0100
+++ /var/tmp/diff_new_pack.S8eUVG/_new 2024-02-25 14:06:26.297593191 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-django-requests-debug-toolbar
#
-# Copyright (c) 2023 SUSE LLC
+# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,12 +18,12 @@
%{?sle15_python_module_pythons}
Name: python-django-requests-debug-toolbar
-Version: 0.0.5
+Version: 0.0.7
Release: 0
Summary: A Django Debug Toolbar panel for Requests
License: MIT
URL:
https://github.com/marceltschoppch/django-requests-debug-toolbar
-Source:
https://files.pythonhosted.org/packages/de/15/82c597cc0d7017323a09d2dac5ad0a2818ab278140a063ac0a329690fd6c/django-requests-debug-toolbar-0.0.5.tar.gz
+Source:
https://files.pythonhosted.org/packages/b9/99/ef0d65a8126ca4d426d070b582290552995cd1e1e2b19e98d962be233561/django-requests-debug-toolbar-0.0.7.tar.gz
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
++++++ django-requests-debug-toolbar-0.0.5.tar.gz ->
django-requests-debug-toolbar-0.0.7.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-requests-debug-toolbar-0.0.5/PKG-INFO
new/django-requests-debug-toolbar-0.0.7/PKG-INFO
--- old/django-requests-debug-toolbar-0.0.5/PKG-INFO 2023-05-05
11:22:39.219155800 +0200
+++ new/django-requests-debug-toolbar-0.0.7/PKG-INFO 2024-01-31
08:15:50.815976100 +0100
@@ -1,41 +1,12 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
Name: django-requests-debug-toolbar
-Version: 0.0.5
+Version: 0.0.7
Summary: A Django Debug Toolbar panel for Requests
Home-page: https://github.com/marceltschoppch/django-requests-debug-toolbar
Author: Marcel Tschopp
Author-email: [email protected]
License: MIT
-Description: django-requests-debug-toolbar
- =============================
-
- A `Django Debug Toolbar
<https://django-debug-toolbar.readthedocs.io/>`_ panel for Requests
-
- About
- -----
-
- Django Requests Debug Toolbar tracks all HTTP requests made with the
popular
- `requests <https://requests.readthedocs.io/>`_ library.
-
-
- Usage
- -----
-
- #. Install using pip::
-
- pip install django-requests-debug-toolbar
-
- #. Add ``requests_panel`` to your ``INSTALLED_APPS`` setting.
- #. Add ``requests_panel.panel.RequestsDebugPanel`` to your
``DEBUG_TOOLBAR_PANELS``.
-
-
- Contributing
- ------------
-
- All suggestions are welcome.
-
Keywords: django django-debug-toolbar requests debug toolbar
-Platform: UNKNOWN
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 2.2
@@ -49,3 +20,33 @@
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
+License-File: LICENSE
+Requires-Dist: django-debug-toolbar>=2.2
+
+django-requests-debug-toolbar
+=============================
+
+A `Django Debug Toolbar <https://django-debug-toolbar.readthedocs.io/>`_ panel
for Requests
+
+About
+-----
+
+Django Requests Debug Toolbar tracks all HTTP requests made with the popular
+`requests <https://requests.readthedocs.io/>`_ library.
+
+
+Usage
+-----
+
+#. Install using pip::
+
+ pip install django-requests-debug-toolbar
+
+#. Add ``requests_panel`` to your ``INSTALLED_APPS`` setting.
+#. Add ``requests_panel.panel.RequestsDebugPanel`` to your
``DEBUG_TOOLBAR_PANELS``.
+
+
+Contributing
+------------
+
+All suggestions are welcome.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-requests-debug-toolbar-0.0.5/django_requests_debug_toolbar.egg-info/PKG-INFO
new/django-requests-debug-toolbar-0.0.7/django_requests_debug_toolbar.egg-info/PKG-INFO
---
old/django-requests-debug-toolbar-0.0.5/django_requests_debug_toolbar.egg-info/PKG-INFO
2023-05-05 11:22:39.000000000 +0200
+++
new/django-requests-debug-toolbar-0.0.7/django_requests_debug_toolbar.egg-info/PKG-INFO
2024-01-31 08:15:50.000000000 +0100
@@ -1,41 +1,12 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
Name: django-requests-debug-toolbar
-Version: 0.0.5
+Version: 0.0.7
Summary: A Django Debug Toolbar panel for Requests
Home-page: https://github.com/marceltschoppch/django-requests-debug-toolbar
Author: Marcel Tschopp
Author-email: [email protected]
License: MIT
-Description: django-requests-debug-toolbar
- =============================
-
- A `Django Debug Toolbar
<https://django-debug-toolbar.readthedocs.io/>`_ panel for Requests
-
- About
- -----
-
- Django Requests Debug Toolbar tracks all HTTP requests made with the
popular
- `requests <https://requests.readthedocs.io/>`_ library.
-
-
- Usage
- -----
-
- #. Install using pip::
-
- pip install django-requests-debug-toolbar
-
- #. Add ``requests_panel`` to your ``INSTALLED_APPS`` setting.
- #. Add ``requests_panel.panel.RequestsDebugPanel`` to your
``DEBUG_TOOLBAR_PANELS``.
-
-
- Contributing
- ------------
-
- All suggestions are welcome.
-
Keywords: django django-debug-toolbar requests debug toolbar
-Platform: UNKNOWN
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 2.2
@@ -49,3 +20,33 @@
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
+License-File: LICENSE
+Requires-Dist: django-debug-toolbar>=2.2
+
+django-requests-debug-toolbar
+=============================
+
+A `Django Debug Toolbar <https://django-debug-toolbar.readthedocs.io/>`_ panel
for Requests
+
+About
+-----
+
+Django Requests Debug Toolbar tracks all HTTP requests made with the popular
+`requests <https://requests.readthedocs.io/>`_ library.
+
+
+Usage
+-----
+
+#. Install using pip::
+
+ pip install django-requests-debug-toolbar
+
+#. Add ``requests_panel`` to your ``INSTALLED_APPS`` setting.
+#. Add ``requests_panel.panel.RequestsDebugPanel`` to your
``DEBUG_TOOLBAR_PANELS``.
+
+
+Contributing
+------------
+
+All suggestions are welcome.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-requests-debug-toolbar-0.0.5/requests_panel/__init__.py
new/django-requests-debug-toolbar-0.0.7/requests_panel/__init__.py
--- old/django-requests-debug-toolbar-0.0.5/requests_panel/__init__.py
2023-05-05 11:22:14.000000000 +0200
+++ new/django-requests-debug-toolbar-0.0.7/requests_panel/__init__.py
2024-01-31 08:12:52.000000000 +0100
@@ -1 +1 @@
-__version__ = '0.0.5'
+__version__ = '0.0.7'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-requests-debug-toolbar-0.0.5/requests_panel/panel.py
new/django-requests-debug-toolbar-0.0.7/requests_panel/panel.py
--- old/django-requests-debug-toolbar-0.0.5/requests_panel/panel.py
2023-05-05 11:20:47.000000000 +0200
+++ new/django-requests-debug-toolbar-0.0.7/requests_panel/panel.py
2024-01-31 08:11:03.000000000 +0100
@@ -1,17 +1,24 @@
import cgi
+import contextlib
import json
import threading
+from contextvars import ContextVar
from debug_toolbar import settings as dt_settings
from debug_toolbar.panels import Panel
-from debug_toolbar.utils import get_stack, render_stacktrace, ThreadCollector,
tidy_stacktrace
+from debug_toolbar.utils import get_stack, render_stacktrace, tidy_stacktrace
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _, ngettext
import requests
import requests.sessions
-collector = ThreadCollector()
+collected_requests = ContextVar('djdt_requests_collected_requests')
+
+
+def collect(request_info):
+ with contextlib.suppress(LookupError):
+ collected_requests.get().append(request_info)
class RequestInfo:
@@ -38,16 +45,24 @@
return json.dumps(json.loads(content), indent=2, sort_keys=True)
except Exception:
# ignore JSON parse exceptions and return unparsed body instead
+ import logging
+ logging.getLogger(__name__).exception('')
pass
return content
+ def _is_json(self, content_type):
+ if not content_type:
+ return False
+ media_type, sub = content_type.split('/', 1)
+ return media_type == 'application' and sub.split('+').pop() == 'json'
+
@cached_property
def request_body(self):
if self.request.body:
content_type = self.request.headers.get('content-type')
if content_type:
content_type, params = cgi.parse_header(content_type)
- if content_type == 'application/json':
+ if self._is_json(content_type):
return self._format_json(self.request.body)
if isinstance(self.request.body, bytes) and
params.get('charset'):
return self.request.body.decode(params['charset'])
@@ -61,11 +76,12 @@
@cached_property
def response_content(self):
if self.response.content:
- if self.response.headers['content-type'] == 'application/json':
- return self._format_json(self.response.content)
- if isinstance(self.response.content, bytes):
- return self.response.content.decode(self.response.encoding)
- return self.response.content
+ if self.response.headers.get('content-type'):
+ content_type, params =
cgi.parse_header(self.response.headers['content-type'])
+ if self._is_json(content_type):
+ return self._format_json(self.response.content)
+ return self.response.text
+ return self.response.text
class PatchedSession(requests.sessions.Session):
@@ -75,7 +91,7 @@
def send(self, request, **kwargs):
response = super().send(request, **kwargs)
- collector.collect(RequestInfo(request, response, kwargs))
+ collect(RequestInfo(request, response, kwargs))
return response
@@ -95,23 +111,24 @@
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
- self._local = threading.local()
+ self.request_count = 0
+ self.collected_requests = []
@property
def nav_subtitle(self):
- request_count = getattr(self._local, 'request_count', 0)
- return ngettext('%(count)s request', '%(count)s requests',
request_count) % {
- 'count': request_count,
+ return ngettext('%(count)s request', '%(count)s requests',
self.request_count) % {
+ 'count': self.request_count,
}
def process_request(self, request):
- collector.clear_collection()
- return super().process_request(request)
+ reset_token = collected_requests.set([])
+ response = super().process_request(request)
+ self.collected_requests = collected_requests.get().copy()
+ collected_requests.reset(reset_token)
+ return response
def generate_stats(self, request, response):
- requests = collector.get_collection()
- collector.clear_collection()
- self._local.request_count = len(requests)
+ self.request_count = len(self.collected_requests)
self.record_stats({
- 'requests': requests,
+ 'requests': self.collected_requests,
})