Add support for easy pagination with the web API.

Review Request #1460 — Created March 6, 2010 and submitted




Add support for easy pagination with the web API.

This introduces a new WebAPIPaginated class that returns a response with
built-in pagination. It takes a queryset and some optional values for the
keys in the payload, default number of entries returned in a response, and
maximum number of entries that can be requested in a single response.

The class handles 'start' and 'max-results' parameters to the URL, which
specify the first item's index (0-based) and the maximum number of items
that will be returned.

The response payload contains the results as a list, the total number of
objects (used to calculate how many requests would be needed), and
URLs for previous and next queries.

Add support for Basic Auth to the web API.

This adds support for Basic Authentication for the web API. Now if any page
presents an Access Denied error, it will do so with an HTTP 401 Unauthorized
error and a WWW-Authentication header saying to use basic authentication.
Clients can provide the username and password in a standard way, and we'll
authenticate them.

Clients no longer have to know to use the /account/login/ page before calling
any other API calls. This is especially useful for clients that don't really
know anything specific about the Review Board API. For example, wget or curl.
Tested some of the URLs in Review Board that now use this. Manually stepped through a list with different start and max-results values and saw the payloads I expected.
  1. Just one thing to check:
  2. djblets/webapi/ (Diff revision 1)
    Wasn't this part of a different change?
    1. Forgot to do a parent diff.