Add closing/reopening signals
Review Request #7332 — Created May 25, 2015 and discarded
Fire "review_request_closing" when attempting to close a review request. If a signal receiver raises a CloseError abort the close operation. This signal allows extensions to prevent a review request from being closed. Alert the user in the UI when a close request has failed. Also introduce a new "review_request_reopening" signal which behaves the same way as the closing signal but deals with reopening review requests. These new signals expand upon publishing signals that were previously added to allow extensions control over publishing - see commit ab84ccdf3d5bb883f18d34133c30af410c7ff1d2
Wrote a dummy extension to raise the new errors inside of the new
signals - API requests were properly blocked and the error messages
were alerted to the user.Compared change description behaviour to Review Board without this
change and observed it to be unchanged after the patch.
Description | From | Last Updated |
---|---|---|
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 48 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 48 E128 continuation line under-indented for visual indent |
reviewbot | |
Can you add docstrings to these? I kind of wish we had prefixed all the others with "ReviewRequest," to differentiate … |
chipx86 | |
You shoul use super(CloseError, self).__init__(msg) here. Same in ReopenError |
brennie | |
Can we do something more graceful than an alert ? |
brennie | |
Can we have this be "... while closing the review request." ? |
chipx86 | |
Same here with reopening. |
chipx86 | |
I want to make sure this doesn't change the semantics around any piece of draft/changedescription creation, since we're reordering the … |
chipx86 | |
"An error that occurs while..." |
brennie | |
"An error that occurs while attempting..." |
brennie | |
Single quotes. |
brennie | |
Single quotes. |
brennie | |
Exceptions take a message string in the arguments by default, so we should work with that and not have our … |
chipx86 | |
Since this is a human-readable string, I'd prefer something less terse, like 'Error closing the review request: %s' I also … |
chipx86 | |
While here, can you put these in alphabetical order? |
chipx86 | |
Let's do one keyword argument per line, to help with readability. |
chipx86 | |
Here too. |
chipx86 | |
Should use single quotes. Here and the new one below (or all of them). Also, we're starting to add docs … |
chipx86 | |
Same here. |
chipx86 | |
With the above changes, this would be: return CLOSE_ERROR.with_message(six.text_type(e)) |
chipx86 |
- Change Summary:
-
Fix Review Bot's issues.
- Commit:
-
56d6cd39739c3a399181a69bfd0439752e3396479b765260311be8e8542d37e1092a48b8269678f7
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/review_request.py reviewboard/webapi/errors.py reviewboard/reviews/signals.py reviewboard/reviews/errors.py reviewboard/reviews/models/review_request.py Ignored Files: reviewboard/static/rb/js/views/reviewRequestEditorView.js Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/review_request.py reviewboard/webapi/errors.py reviewboard/reviews/signals.py reviewboard/reviews/errors.py reviewboard/reviews/models/review_request.py Ignored Files: reviewboard/static/rb/js/views/reviewRequestEditorView.js
-
-
Can you add docstrings to these?
I kind of wish we had prefixed all the others with "ReviewRequest," to differentiate between publishing other sorts of things. Wonder if we should start that precedence here or not...
-
-
-
I want to make sure this doesn't change the semantics around any piece of draft/changedescription creation, since we're reordering the operations here. I went through and I think it's okay, and we might actually have been leaking a ChangeDescription entry in the database before that this would fix. Still, to be sure, can you do some testing around:
- Discarding an unpublished review request, and reopening it.
- Discarding a published review request, and reopening it.
- Closing a published review request as submitted, and reopening it.
For each of these, make sure there's no change description sitting there on the page after, and then try publishing and make sure you see the expected change description.
- Change Summary:
-
Updated based on reviews and did more testing.
- Testing Done:
-
Wrote a dummy extension to raise the new errors inside of the new
signals - API requests were properly blocked and the error messages were alerted to the user. + + Compared change description behaviour to Review Board without this
+ change and observed it to be unchanged after the patch. - Commit:
-
9b765260311be8e8542d37e1092a48b8269678f75d43e217f797aa4e8ba85cb30f6217528ddb79c2
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/review_request.py reviewboard/webapi/errors.py reviewboard/reviews/signals.py reviewboard/reviews/errors.py reviewboard/reviews/models/review_request.py Ignored Files: reviewboard/static/rb/js/views/reviewRequestEditorView.js Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/review_request.py reviewboard/webapi/errors.py reviewboard/reviews/signals.py reviewboard/reviews/errors.py reviewboard/reviews/models/review_request.py Ignored Files: reviewboard/static/rb/js/views/reviewRequestEditorView.js
- Change Summary:
-
Updated based on Barret's review.
- Commit:
-
5d43e217f797aa4e8ba85cb30f6217528ddb79c2ce68da631a9752f2c3cbc90edd1ffd2077b1e533
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/review_request.py reviewboard/webapi/errors.py reviewboard/reviews/signals.py reviewboard/reviews/errors.py reviewboard/reviews/models/review_request.py Ignored Files: reviewboard/static/rb/js/views/reviewRequestEditorView.js Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/review_request.py reviewboard/webapi/errors.py reviewboard/reviews/signals.py reviewboard/reviews/errors.py reviewboard/reviews/models/review_request.py Ignored Files: reviewboard/static/rb/js/views/reviewRequestEditorView.js
-
-
Exceptions take a message string in the arguments by default, so we should work with that and not have our own
msg
field. (The others probably should be updated to do the right thing here as well.) -
Since this is a human-readable string, I'd prefer something less terse, like
'Error closing the review request: %s'
I also don't think we should be overriding
__str__
on any of these. Instead, we should do what other exceptions do and build a finalized string in__init__
, like:def __init__(self, msg): super(CloseError, self).__init__( 'Error closing the review request: %s' % msg)
These comments all apply to the other exceptions as well.
-
-
-
-
Should use single quotes. Here and the new one below (or all of them).
Also, we're starting to add docs for all these sorts of things, for the new codebase docs. Can you prefix these with things like:
#: Emitted when a review request is about to be closed. #: #: <whatever other details> #: #: Args: #: user (User): #: <description of user> #: #: review_request (ReviewRequest): #: <description of review request> #: #: ...
This will result in a nicely-formatted set of docs. (The above will be parsed by a Sphinx extension we're now using to produce proper argument docs with types.)
If these can return a value, then add to the end:
#: Returns: #: <type>: <description>
-
-