[Patchew-devel] [PATCH 2/2] www: provide a quick way to download patches as mbox file
Fam Zheng
famz at redhat.com
Thu Aug 2 09:13:26 UTC 2018
On Thu, 08/02 11:00, Paolo Bonzini wrote:
> On 02/08/2018 10:48, Fam Zheng wrote:
> > On Mon, 07/30 12:44, Paolo Bonzini wrote:
> >> The "download mbox" file downloads the entire thread, which is rarely
> >> what you want to do. Provide an alternative download link that only
> >> includes the patches and, when the tags module is active, includes the
> >> tags into the mbox.
> >>
> >> Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
> >> ---
> >> mods/tags.py | 47 +++++++++++++++++++++++++++++++-
> >> www/templates/series-detail.html | 6 ++--
> >> www/urls.py | 1 +
> >> www/views.py | 11 ++++++++
> >> 4 files changed, 61 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/mods/tags.py b/mods/tags.py
> >> index aa29c60..f7b0300 100644
> >> --- a/mods/tags.py
> >> +++ b/mods/tags.py
> >> @@ -10,11 +10,13 @@
> >>
> >> from mod import PatchewModule
> >> from mbox import parse_address
> >> +from django.http import HttpResponse, Http404
> >> from event import register_handler, emit_event, declare_event
> >> from api.models import Message
> >> from api.rest import PluginMethodField
> >> from patchew.tags import lines_iter
> >> import re
> >> +import www.views
> >>
> >> REV_BY_PREFIX = "Reviewed-by:"
> >> BASED_ON_PREFIX = "Based-on:"
> >> @@ -27,6 +29,21 @@ tags = Tested-by, Reported-by, Acked-by, Suggested-by
> >>
> >> BUILT_IN_TAGS = [REV_BY_PREFIX, BASED_ON_PREFIX]
> >>
> >> +_instance = None
> >> +
> >> +# This is monkey-patched into www.views
> >> +def _view_series_mbox_patches(request, project, message_id):
> >> + global _instance
> >> + s = Message.objects.find_series(message_id, project)
> >> + if not s:
> >> + raise Http404("Series not found")
> >> + if not s.is_complete:
> >> + raise Http404("Series not complete")
> >> + mbox = "\n".join(["From %s %s\n" % (x.get_sender_addr(), x.get_asctime()) + \
> >> + _instance.get_mbox_with_tags(x) for x in s.get_patches()])
> >> + return HttpResponse(mbox, content_type="text/plain")
> >> +www.views.view_series_mbox_patches = _view_series_mbox_patches
> >
> > Maybe instead use the dispatch_module_hook() approach?
>
> Yes, or alternatively make tags first-class citizens that the core knows
> about, similar to how "version" is part of the model and mods/diff.py
> only provides the UI. In this case, the only purpose of the tags module
> is to collect them.
No objection from a modeling perspective, but having all tags stored in a JSON
field is probably more efficient to a 1:N relationship like Results.
Fam
More information about the Patchew-devel
mailing list