From nobody Mon Apr 29 10:46:46 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=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525160142035429.97404717644133; Tue, 1 May 2018 00:35:42 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 35E5B3003A21; Tue, 1 May 2018 07:35:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2311B341F6; Tue, 1 May 2018 07:35:40 +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 C98101808841; Tue, 1 May 2018 07:35:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w417Zd0Z012857 for ; Tue, 1 May 2018 03:35:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id B574A6092F; Tue, 1 May 2018 07:35:39 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE34C6090C for ; Tue, 1 May 2018 07:35:36 +0000 (UTC) Received: from mail-pf0-f170.google.com (mail-pf0-f170.google.com [209.85.192.170]) (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 DFF1B315008C for ; Tue, 1 May 2018 07:35:25 +0000 (UTC) Received: by mail-pf0-f170.google.com with SMTP id f189so8634564pfa.7 for ; Tue, 01 May 2018 00:35:25 -0700 (PDT) Received: from localhost.localdomain ([14.141.249.170]) by smtp.gmail.com with ESMTPSA id x2sm21639777pfk.113.2018.05.01.00.35.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 00:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=GnC1YnkaF1BD3dSCdvVN0dhscPjPiDxdaJJ5xPuaLFo=; b=ifTHtV/YspcucphdUGJ+w6vnZ7f/zo/ZVt86Q3bdybxvArDyKDF5V2GmW73MxCbd05 2PI2E1UNADT/qAsBt2odH14bjzglJ/t9KRKD52kYN5Ile2bxYm1egYh80NszEl1LYl+h KgMu4qeebO2PWmTMqwgb0jHD5OOrV9BP+I5WGZkrOPR0wFtvsMGT+q+/ZoL9O/Lvagz+ 0yN7Qla4w18MxvPXTIVNAUeXWwWc50muh08DQrfgnxmv309pr2rhcK2u11fEpZ/Ml1YO E97QR6O+HDeJlVLTMA405c71oplaEycwJknVHMBofR9ZExazltztgN+8kMKiMQy4Wrbi v4Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=GnC1YnkaF1BD3dSCdvVN0dhscPjPiDxdaJJ5xPuaLFo=; b=qEGhLZ16PVN1FMO5X3lceKRJbAq+z1UHtuRjYqpezbyCckU460IwcEkniNEn/e2VaI G9DP4ID4tlevpUx+1FBU9FsrTNWLbyjpyHCprnMLmCP+BEyFJ3HpYbsEh8a9NEVM18qT TnGXc41uvNv11raC1eoejskvvoS3Y6B4PA7dfBW2frYh+Nc9bGnpPrQVKxHBEjXtwFQ8 X7+GX8nJhYFRsZWJGd3WWyx9DliTMsgutWwWyKwKAV9T0ls4UByne9zSIyiTTOxXaUWO RnghvG2nVIgkyvx3IJ6kCRWSO2aZsIZTXzPc/WPHchURF5hfYorRsrntIv198+88z0og 8ghw== X-Gm-Message-State: ALQs6tB68xqWGe4z+se0UKHvr0HBL4QVtJLOOAzPzMhUFvSc59f7S+cF jkygW5c4tB7r58F9mHztVX1D5A== X-Google-Smtp-Source: AB8JxZpQLXfl5L/Qr/VzcF07J8oQsQxFgjY4OOAgp4MRw3ToDi7qieBUfEi1PgbHCuBgfFsn1hAt8w== X-Received: by 2002:a63:6110:: with SMTP id v16-v6mr12108877pgb.292.1525160124600; Tue, 01 May 2018 00:35:24 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Tue, 1 May 2018 13:05:10 +0530 Message-Id: <20180501073510.17951-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 01 May 2018 07:35:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 01 May 2018 07:35:26 +0000 (UTC) for IP:'209.85.192.170' DOMAIN:'mail-pf0-f170.google.com' HELO:'mail-pf0-f170.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.55 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.192.170 mail-pf0-f170.google.com 209.85.192.170 mail-pf0-f170.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH] Change "mbox" to use getters and setters instead of SerializerMethodField - Rename the existing "mbox" field to e.g. "mbox_blob" - Add getters and setters for "mbox" to api.models.Message 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 01 May 2018 07:35:41 +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" --- api/models.py | 24 ++++++++++++++---------- api/rest.py | 5 +---- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/api/models.py b/api/models.py index 4cc2b74..13ec44e 100644 --- a/api/models.py +++ b/api/models.py @@ -245,12 +245,12 @@ class MessageManager(models.Manager): self.delete_subthread(r) msg.delete() =20 - def add_message_from_mbox(self, mbox, user, project_name=3DNone): + def add_message_from_mbox(self, mbox_blob, user, project_name=3DNone): =20 def find_message_projects(m): return [p for p in Project.objects.all() if p.recognizes(m)] =20 - m =3D MboxMessage(mbox) + m =3D MboxMessage(mbox_blob) msgid =3D m.get_message_id() if project_name: projects =3D [Project.object.get(name=3Dproject_name)] @@ -272,7 +272,7 @@ class MessageManager(models.Manager): msg.project =3D p if self.filter(message_id=3Dmsgid, project__name=3Dp.name).fir= st(): raise self.DuplicateMessageError(msgid) - msg.save_mbox(mbox) + msg.save_mbox(mbox_blob) msg.save() emit_event("MessageAdded", message=3Dmsg) self.update_series(msg) @@ -318,20 +318,24 @@ class Message(models.Model): num_patches =3D models.IntegerField(null=3DFalse, default=3D-1, blank= =3DTrue) =20 objects =3D MessageManager() + def _get_mbox_blob(self): + return self.get_mbox() =20 =20 - def save_mbox(self, mbox): - save_blob(mbox, self.message_id) + mbox =3D property(_get_mbox_blob) + + def save_mbox(self, mbox_blob): + save_blob(mbox_blob, self.message_id) =20 def get_mbox_obj(self): self.get_mbox() return self._mbox_obj =20 def get_mbox(self): - if hasattr(self, "mbox"): - return self.mbox - self.mbox =3D load_blob(self.message_id) - self._mbox_obj =3D MboxMessage(self.mbox) - return self.mbox + if hasattr(self, "mbox_blob"): + return self.mbox_blob + self.mbox_blob =3D load_blob(self.message_id) + self._mbox_obj =3D MboxMessage(self.mbox_blob) + return self.mbox_blob =20 def get_num(self): assert self.is_patch or self.is_series_head diff --git a/api/rest.py b/api/rest.py index 5610844..a2ab004 100644 --- a/api/rest.py +++ b/api/rest.py @@ -287,10 +287,7 @@ class MessageSerializer(BaseMessageSerializer): class Meta: model =3D Message fields =3D BaseMessageSerializer.Meta.fields + ('mbox', ) - def get_mbox(self, obj): - return obj.get_mbox() - mbox =3D SerializerMethodField() - + =20 def get_fields(self): fields =3D super(MessageSerializer, self).get_fields() request =3D self.context['request'] --=20 2.14.3 (Apple Git-98) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel