From nobody Mon Dec 15 03:19:52 2025 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 206.53.239.180 is neither permitted nor denied by domain of freelists.org) client-ip=206.53.239.180; envelope-from=patchew-devel-bounce@freelists.org; helo=turing.freelists.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=none (zoho.com: 206.53.239.180 is neither permitted nor denied by domain of freelists.org) smtp.mailfrom=patchew-devel-bounce@freelists.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from turing.freelists.org (turing.freelists.org [206.53.239.180]) by mx.zohomail.com with SMTPS id 1520412393728943.0393859738844; Wed, 7 Mar 2018 00:46:33 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 23B9326352; Wed, 7 Mar 2018 03:46:24 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S_zm5tPgYJFB; Wed, 7 Mar 2018 03:46:24 -0500 (EST) Received: from turing.freelists.org (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id C20B9260D3; Wed, 7 Mar 2018 03:46:23 -0500 (EST) Received: with ECARTIS (v1.0.0; list patchew-devel); Wed, 07 Mar 2018 03:46:23 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 96C9526352 for ; Wed, 7 Mar 2018 03:46:23 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mAwnK03LOZBc for ; Wed, 7 Mar 2018 03:46:23 -0500 (EST) Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 7C435260D3 for ; Wed, 7 Mar 2018 03:46:23 -0500 (EST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 39CB440363BE for ; Wed, 7 Mar 2018 08:46:23 +0000 (UTC) Received: from lemon.usersys.redhat.com (ovpn-12-131.pek2.redhat.com [10.72.12.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7CFF1C70E; Wed, 7 Mar 2018 08:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=freelists.org; s=turing; t=1520412384; bh=1wk8Oo60z9xxy9oT4FTdbWAX99BmLU4jUb5EmT9fgQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:Reply-To:List-help: List-unsubscribe:List-Id:List-subscribe:List-owner:List-post: List-archive; b=MehyR+yPoIxJ8H0zdvGNARyaVCj/7UklWDu5W6lBkAujOGKFT9x7SaoySuZrG3Acz Kl8eGC/I0vzMx348fUZhndV+fUZRimixhhJvkZHgX1uBsNP0vw9TJN92eu3XW4ushC /nsxuyuz8t5GeQBUWv/ZIUJ4ODGWZ6JsmIdQijy8= X-Virus-Scanned: Debian amavisd-new at turing.freelists.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=freelists.org; s=turing; t=1520412384; bh=1wk8Oo60z9xxy9oT4FTdbWAX99BmLU4jUb5EmT9fgQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:Reply-To:List-help: List-unsubscribe:List-Id:List-subscribe:List-owner:List-post: List-archive; b=MehyR+yPoIxJ8H0zdvGNARyaVCj/7UklWDu5W6lBkAujOGKFT9x7SaoySuZrG3Acz Kl8eGC/I0vzMx348fUZhndV+fUZRimixhhJvkZHgX1uBsNP0vw9TJN92eu3XW4ushC /nsxuyuz8t5GeQBUWv/ZIUJ4ODGWZ6JsmIdQijy8= X-Original-To: patchew-devel@freelists.org X-Virus-Scanned: Debian amavisd-new at turing.freelists.org From: Fam Zheng To: patchew-devel@freelists.org Cc: pbonzini@redhat.com Subject: [patchew-devel] [PATCH 2/7] Add SetProperty event Date: Wed, 7 Mar 2018 16:46:04 +0800 Message-Id: <20180307084609.8515-3-famz@redhat.com> In-Reply-To: <20180307084609.8515-1-famz@redhat.com> References: <20180307084609.8515-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 08:46:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 07 Mar 2018 08:46:23 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'famz@redhat.com' RCPT:'' X-archive-position: 86 X-ecartis-version: Ecartis v1.0.0 Sender: patchew-devel-bounce@freelists.org Errors-to: patchew-devel-bounce@freelists.org X-original-sender: famz@redhat.com Precedence: normal Reply-To: patchew-devel@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: patchew-devel X-List-ID: patchew-devel List-subscribe: List-owner: List-post: List-archive: X-list: patchew-devel X-ZohoMail-DKIM: pass (identity @freelists.org) X-ZohoMail-Owner: <20180307084609.8515-3-famz@redhat.com>+zmo_0_patchew-devel-bounce@freelists.org X-ZohoMail: RDKM_0 RSF_4 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It is emitted after new properties are saved on Project or Message objects. Signed-off-by: Fam Zheng --- api/models.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/api/models.py b/api/models.py index 0c8688a..2055957 100644 --- a/api/models.py +++ b/api/models.py @@ -102,7 +102,7 @@ class Project(models.Model): r[m.name] =3D json.loads(m.value) return r =20 - def set_property(self, prop, value): + def _do_set_property(self, prop, value): if value =3D=3D None: ProjectProperty.objects.filter(project=3Dself, name=3Dprop).de= lete() return @@ -119,6 +119,12 @@ class Project(models.Model): pp.blob =3D blob pp.save() =20 + def set_property(self, prop, value): + old_val =3D self.get_property(prop) + self._do_set_property(prop, value) + emit_event("SetProperty", obj=3Dself, name=3Dprop, value=3Dvalue, + old_value=3Dold_val) + def total_series_count(self): return Message.objects.series_heads(project=3Dself.name).count() =20 @@ -176,6 +182,11 @@ declare_event("SeriesComplete", project=3D"project obj= ect", =20 declare_event("MessageAdded", message=3D"message object that is added") =20 +declare_event("SetProperty", obj=3D"object to set the property", + name=3D"name of the property", + value=3D"value of the property", + old_value=3D"old value if any") + class MessageManager(models.Manager): =20 class DuplicateMessageError(Exception): @@ -408,7 +419,7 @@ class Message(models.Model): self._properties =3D r return r =20 - def set_property(self, prop, value): + def _do_set_property(self, prop, value): if value =3D=3D None: MessageProperty.objects.filter(message=3Dself, name=3Dprop).de= lete() return @@ -427,6 +438,12 @@ class Message(models.Model): if hasattr(self, '_properties'): del(self._properties) =20 + def set_property(self, prop, value): + old_val =3D self.get_property(prop) + self._do_set_property(prop, value) + emit_event("SetProperty", obj=3Dself, name=3Dprop, value=3Dvalue, + old_value=3Dold_val) + def get_sender(self): return json.loads(self.sender) =20 --=20 2.14.3