Re: FR: Option to terminate page rendering from an Action nicely
"John P. Rouillard" <[email protected]>
| Newsgroups | gmane.comp.bug-tracking.roundup.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Nagy:
In message <20210831013511.37404b03@Dell>, Nagy Gabor writes:
>Thank you both for your replies. I like both proposals, and I find
>John's concept elegant. I also agree with Ralf that the handling of
>return values of Actions should be documented.
I think your patch forcing a check of HTML against a boolean:
if html == True:
return
would work. We can define True as meaning that HTML has been sent.
However I think sending output from an action rather than returning
the output is an anti-pattern. Also I think writing to the client from
the action bypasses the new output compression (gzip, brotli etc.)
code path.
>> I just implmented
>>
>> https://wiki.roundup-tracker.org/QueryResultPieCharts
>>
>> using pygal.
I was able to make an action that produces a png image using pygal. I
returned the image action to the caller and it was properly displayed.
So it looks like it will work. (Note it wasn't compressed because
image/png is excluded from compression.)
>PS. A bit off-topic in this thread, but John's email reminded me that I
>do not really like the current implementation of ExportCSVAction in
>cgi/actions.py (or the index templates in the sample trackers, it
>depends on your point of view): In my opinion, ExportCSVAction and the
>index templates _should_ somehow share the code which renders the
>"cells of the table" of the index view: We should export precisely
>what the user sees. However, instead of code sharing, there are many
>hardcoded stuff in ExportCSVAction (see the 'name' vs. 'realname'
>handling etc.).
You can create a new ExportCSVAction for your tracker and if you like
it, add it to the wiki. See:
https://wiki.roundup-tracker.org/ExportCSVNames_Extended
for example. You can also register your replacement in place of the
export_csv action by adding:
instance.registerAction('export_csv', ExportCSVNamesAction)
inside of init().
Have a great week.
--
-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.