[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

Shubham Jain shubhamjain7495 at gmail.com
Wed May 2 13:55:57 UTC 2018


Pushed it by mistake. Is there any way to revert it?

On Wed 2 May, 2018 7:24 pm Fam Zheng, <famz at redhat.com> wrote:

> On Wed, 05/02 12:01, Paolo Bonzini wrote:
> > On 01/05/2018 09:35, Shubham Jain wrote:
> > > ---
> > >  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()
> > >
> > > -    def add_message_from_mbox(self, mbox, user, project_name=None):
> > > +    def add_message_from_mbox(self, mbox_blob, user,
> project_name=None):
> > >
> > >          def find_message_projects(m):
> > >              return [p for p in Project.objects.all() if
> p.recognizes(m)]
> > >
> > > -        m = MboxMessage(mbox)
> > > +        m = MboxMessage(mbox_blob)
> > >          msgid = m.get_message_id()
> > >          if project_name:
> > >              projects = [Project.object.get(name=project_name)]
> > > @@ -272,7 +272,7 @@ class MessageManager(models.Manager):
> > >              msg.project = p
> > >              if self.filter(message_id=msgid, project__name=p.name
> ).first():
> > >                  raise self.DuplicateMessageError(msgid)
> > > -            msg.save_mbox(mbox)
> > > +            msg.save_mbox(mbox_blob)
> > >              msg.save()
> > >              emit_event("MessageAdded", message=msg)
> > >              self.update_series(msg)
> > > @@ -318,20 +318,24 @@ class Message(models.Model):
> > >      num_patches = models.IntegerField(null=False, default=-1,
> blank=True)
> > >
> > >      objects = MessageManager()
> > > +    def _get_mbox_blob(self):
> > > +        return self.get_mbox()
> > >
> > > -    def save_mbox(self, mbox):
> > > -        save_blob(mbox, self.message_id)
> > > +    mbox = property(_get_mbox_blob)
> >
> > This can be simply "mbox = property(get_mbox)", right?  There should be
> > no need to add _get_mbox_blob.  After this is changed, we can look at
> > adding a setter for the mbox property.
> >
> > Fam, could you please review this patch?  It's more your area. :)
>
> Looks good to me, except the long subject could be broken into a proper
> commit
> message. :)
>
> Fam
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/patchew-devel/attachments/20180502/409f023f/attachment.htm>


More information about the Patchew-devel mailing list