New python API

Review Request #2508 — Created Aug. 3, 2011 and discarded — Latest diff uploaded

Information

RBTools

Reviewers

New API is designed to provide simple and efficient access to RB resources, it employs 'factory' pattern and code generation to parse resource JSON structure and make pythons objects on the top of it. The code posted here is not complete as it turned out that heavy changes that mostly have subjects to change are hard to review and redo.

Related discussion is here:
https://groups.google.com/d/topic/reviewboard-dev/HFm7rz4QE2k/discussion

For a while there are no tests, so you can run this code
to ensure that the new API works:

from textwrap import wrap

from rbtools.api.server import RBServer
from rbtools.api.settings import Settings


server = RBServer('http://reviews.reviewboard.org/')
root = server.get_root()

width = 80
review_requests = root.get_review_requests()
for rr in review_requests:
    print '\n', (' ' + rr.summary + ' ').center(width, '='), '\n'
    for line in wrap(rr.description, width):
        print line


Corresponding branch is at http://github.com/mbait/rbtools/tree/resources