Change how parsing of response payloads works.

Review Request #4213 — Created June 6, 2013 and submitted

Information

Review Board
master

Reviewers

Change how parsing of response payloads works.

Previously, every resource had to override parse(), call the parent
parse(), grab the contents of the payload within the envelope, and then
set each field in the response from the parent parse() and return it.

The problem with that is that only works if we have the envelope. That
won't work from list resources.

Now, subclasses override parseResourceData, which only needs to return
the data specific to the subclass. The rsp it parses from is guaranteed
to be within the envelope, if one exists.

parse() exists only in BaseResource now. It will remove the rsp data
from the envelope if it sees a 'stat' header. Otherwise, it assumes the
data it's dealing with is proper resource data.

This is needed for my upcoming change to introduce
BaseResourceCollection.
All unit tests pass.

My BaseResourceCollection was able to deserialize models after this
change.
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
      Ignored Files:
        reviewboard/static/rb/js/models/baseCommentModel.js
        reviewboard/static/rb/js/models/screenshotCommentModel.js
        reviewboard/static/rb/js/models/tests/diffCommentModelTests.js
        reviewboard/static/rb/js/models/tests/draftReviewRequestModelTests.js
        reviewboard/static/rb/js/models/fileAttachmentCommentModel.js
        reviewboard/static/rb/js/models/reviewReplyModel.js
        reviewboard/static/rb/js/models/draftReviewRequestModel.js
        reviewboard/static/rb/js/models/tests/fileAttachmentModelTests.js
        reviewboard/static/rb/js/models/tests/baseCommentReplyModelTests.js
        reviewboard/static/rb/js/models/fileAttachmentModel.js
        reviewboard/static/rb/js/models/baseResourceModel.js
        reviewboard/static/rb/js/models/tests/reviewModelTests.js
        reviewboard/static/rb/js/models/tests/fileAttachmentCommentModelTests.js
        reviewboard/static/rb/js/models/diffCommentModel.js
        reviewboard/static/rb/js/models/reviewModel.js
        reviewboard/static/rb/js/models/baseCommentReplyModel.js
        reviewboard/static/rb/js/models/tests/screenshotCommentModelTests.js
        reviewboard/static/rb/js/models/tests/baseResourceModelTests.js
        reviewboard/static/rb/js/models/tests/reviewReplyModelTests.js
        reviewboard/static/rb/js/models/abstractCommentModel.js
        reviewboard/static/rb/js/models/tests/baseCommentModelTests.js
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Loading...