From nobody Fri Oct 25 19:22:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1520496055951914.9412712547806; Thu, 8 Mar 2018 00:00:55 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 073D6C04BE07; Thu, 8 Mar 2018 08:00:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB1E017D1C; Thu, 8 Mar 2018 08:00:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E13C04CA99; Thu, 8 Mar 2018 08:00:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2880siq032363 for ; Thu, 8 Mar 2018 03:00:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2507E9F73; Thu, 8 Mar 2018 08:00:54 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DE4E9F72 for ; Thu, 8 Mar 2018 08:00:54 +0000 (UTC) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DA76EC04AC4B for ; Thu, 8 Mar 2018 08:00:52 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id x7so9281804wmc.0 for ; Thu, 08 Mar 2018 00:00:52 -0800 (PST) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id b9sm21755912wrh.68.2018.03.08.00.00.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Mar 2018 00:00:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=iJqLnYTNpTpXBPTFDu7Pv1bb7QZJPS1ExevtXSX+FcU=; b=IcUz8J5l5XxxQ/uFI2blrX++Fh4mupGc4CFeIAsfrK6pR9iz5oQwS4WKNYd2xNH/rr 9W6bFnwHjBvAY/IIqCr9KJCdq4IxqQsyNtsVH1kkFjAH2/viL8HURkB0bSG8IN/75O9h Q8DjqucWkIRfGme0hfssp2djRsqoIHMbLmrj5QxF25x+cto7oQPLngiFtcvQ5vwRd5w+ 6Z+WxkaklMqFnyqn8FGsdEnG5ufpJitOmOhwc0hq7D2iHciYXtsKVvXFvNTFHMzhD5yN 2srxrgkLD8sE4gmygaLKPSTfr3WvIWFaiRmVvQFvM2BJogoQkEnS6XCbjvyIbUEvInjp RheA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=iJqLnYTNpTpXBPTFDu7Pv1bb7QZJPS1ExevtXSX+FcU=; b=SiaxByypz7eejTmjvEO7MSvoxQYd3SNISnUZnOGcCJ3F9ibM6yxbat+5tFPwuu8/h5 1q+a46VnMQsMG5CknhyHknHWRkT9idSWAUA5Iv2bKNV2ATnPDuoJqINI6VEkv70xcgIf ap/qvvmqlPoWTsSL/gVhIxtpK5VJJYP2k5BH6zWvTvB8ESVHAkVC4jg6BSur7iHp8S75 8FZ0zTYGK+2I1ln8lJbdWqW+JFnaGxcLPjX0PP8soChsLPAuo6j6ecRx4LcN2g3pu53d x+Jey82WQqugMm4yTAI0eTmf5TQ+sEfEoSvTHdavafYnoIbzs0bwznrYWCaxeFoX7nd1 h8VQ== X-Gm-Message-State: AElRT7GrQ7OlzWIugQJujr+T87tnRZSoYixgn/cAp1y1n0U5ADbf45FC HPNtglWdj3snmWEVF17lFaHxPcyp X-Google-Smtp-Source: AG47ELuBmiB9wGiFdjypgMFETuG5rRr/tv6QUU8uHJ2xq6yFS7x5iW5CDRqFuK+7a/DcSgdQScUa2w== X-Received: by 10.28.193.134 with SMTP id r128mr16042382wmf.85.1520496051101; Thu, 08 Mar 2018 00:00:51 -0800 (PST) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 8 Mar 2018 09:00:40 +0100 Message-Id: <20180308080042.19342-6-pbonzini@redhat.com> In-Reply-To: <20180308080042.19342-1-pbonzini@redhat.com> References: <20180308080042.19342-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 08 Mar 2018 08:00:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 08 Mar 2018 08:00:53 +0000 (UTC) for IP:'74.125.82.66' DOMAIN:'mail-wm0-f66.google.com' HELO:'mail-wm0-f66.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.469 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 74.125.82.66 mail-wm0-f66.google.com 74.125.82.66 mail-wm0-f66.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 5/7] rest: pass request to hooks X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 08 Mar 2018 08:00:55 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The request is needed by rest_framework.reverse.reverse. It is already passed to the plugins via PluginMethodField, pass it to the hooks as well. Signed-off-by: Paolo Bonzini --- api/rest.py | 12 +++++++++--- mods/diff.py | 2 +- mods/git.py | 2 +- mods/tags.py | 2 +- mods/testing.py | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/api/rest.py b/api/rest.py index be774a9..7c131a4 100644 --- a/api/rest.py +++ b/api/rest.py @@ -171,12 +171,16 @@ class SeriesSerializer(BaseMessageSerializer): =20 def get_fields(self): fields =3D super(SeriesSerializer, self).get_fields() - dispatch_module_hook("rest_series_fields_hook", fields=3Dfields, d= etailed=3Dself.detailed) + request =3D self.context['request'] + dispatch_module_hook("rest_series_fields_hook", request=3Drequest, + fields=3Dfields, detailed=3Dself.detailed) return fields =20 def get_results(self, message): results =3D {} - dispatch_module_hook("rest_results_hook", message=3Dmessage, resul= ts=3Dresults) + request =3D self.context['request'] + dispatch_module_hook("rest_results_hook", request=3Drequest, + message=3Dmessage, results=3Dresults) return results =20 def get_total_patches(self, obj): @@ -276,7 +280,9 @@ class MessageSerializer(BaseMessageSerializer): =20 def get_fields(self): fields =3D super(MessageSerializer, self).get_fields() - dispatch_module_hook("rest_message_fields_hook", fields=3Dfields) + request =3D self.context['request'] + dispatch_module_hook("rest_message_fields_hook", request=3Drequest, + fields=3Dfields) return fields =20 class StaticTextRenderer(renderers.BaseRenderer): diff --git a/mods/diff.py b/mods/diff.py index eb8dfb8..38404e0 100644 --- a/mods/diff.py +++ b/mods/diff.py @@ -60,7 +60,7 @@ class DiffModule(PatchewModule): for o in sorted(other_versions, key=3Dlambda y: y.version) if o.message_id !=3D message.message_id] =20 - def rest_series_fields_hook(self, fields, detailed): + def rest_series_fields_hook(self, request, fields, detailed): fields['version'] =3D rest_framework.fields.IntegerField() if detailed: fields['other_versions'] =3D PluginMethodField(obj=3Dself) diff --git a/mods/git.py b/mods/git.py index b0df7e8..2489f5a 100644 --- a/mods/git.py +++ b/mods/git.py @@ -113,7 +113,7 @@ class GitModule(PatchewModule): raise Exception("Project git repo invalid: %s" % project_git) return upstream, branch =20 - def rest_results_hook(self, message, results): + def rest_results_hook(self, request, message, results): l =3D message.get_property("git.apply-log") if l: if message.get_property("git.apply-failed"): diff --git a/mods/tags.py b/mods/tags.py index 5a776ed..5ec5bc2 100644 --- a/mods/tags.py +++ b/mods/tags.py @@ -123,7 +123,7 @@ series cover letter, patch mail body and their replies. def get_tags(self, m, request, format): return m.get_property("tags", []) =20 - def rest_message_fields_hook(self, fields): + def rest_message_fields_hook(self, request, fields): fields['tags'] =3D PluginMethodField(obj=3Dself) =20 def prepare_message_hook(self, request, message, detailed): diff --git a/mods/testing.py b/mods/testing.py index 47933e2..b822a34 100644 --- a/mods/testing.py +++ b/mods/testing.py @@ -257,7 +257,7 @@ class TestingModule(PatchewModule): return reverse("testing-get-prop", kwargs=3D{"project_or_series": obj.message_id}) =20 - def rest_results_hook(self, message, results): + def rest_results_hook(self, request, message, results): for pn, p in message.get_properties().items(): if not pn.startswith("testing.report."): continue --=20 2.14.3 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel