Add support for custom paginated responses in API resources.

Review Request #5895 — Created May 29, 2014 and submitted

Information

Djblets
release-0.8.x
c64b3de...

Reviewers

WebAPIResource now allows subclasses to set paginated_cls to a
subclass of a WebAPIResponsePaginated. This will be used for handling
the pagination of the resource's queryset and for serializing the data.

WebAPIResponsePaginated has been fully restructured to make its behavior
customizable. Subclasses can override nearly every aspect of it,
including previous/next calculation, URL building, results fetching,
link building, etc. This makes it possible to do such things as paginate
by SHA1, or by page (instead of result item index), or fetch data from
something other than a database-backed queryset.

All Djblets and Review Board unit tests pass.

Implemented a custom paginated response class for use in remote repository
fetching, which needed a different model for pagination (page-based indexes
instead of item-based), and needed to supply slightly different results
(no 'total_results' field). I was able to successfully use it to move back
and forth through results.

Description From Last Updated

'BasicAPIEncoder' imported but unused

reviewbotreviewbot

I think it reads better with "number" instead of "amount".

daviddavid

There's a weird colon in here.

daviddavid

'BasicAPIEncoder' imported but unused

reviewbotreviewbot
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        djblets/webapi/core.py
        djblets/webapi/resources.py
      Ignored Files:
    
    
  2. 
      
reviewbot
  1. This is a review from Review Bot.
      Tool: Pyflakes
      Processed Files:
        djblets/webapi/core.py
        djblets/webapi/resources.py
      Ignored Files:
    
    
  2. djblets/webapi/core.py (Diff revision 1)
     
     
    Show all issues
     'BasicAPIEncoder' imported but unused
    
  3. 
      
david
  1. 
      
  2. djblets/webapi/resources.py (Diff revision 1)
     
     
    Show all issues

    I think it reads better with "number" instead of "amount".

  3. djblets/webapi/resources.py (Diff revision 1)
     
     
    Show all issues

    There's a weird colon in here.

    1. Tools like Sphinx, when generating docs for classses, will look for #: and use it for the doc strings for the attribute following it.

  4. 
      
chipx86
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        djblets/webapi/core.py
        djblets/webapi/resources.py
      Ignored Files:
    
    
  2. 
      
reviewbot
  1. This is a review from Review Bot.
      Tool: Pyflakes
      Processed Files:
        djblets/webapi/core.py
        djblets/webapi/resources.py
      Ignored Files:
    
    
  2. djblets/webapi/core.py (Diff revision 2)
     
     
    Show all issues
     'BasicAPIEncoder' imported but unused
    
  3. 
      
david
  1. Ship It!

  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-0.8.x (928ed77)