REST is nothing more than a design pattern for structuring an API,
generally one backed by HTTP. There's no toolkit, no library that is
required for REST. We are a REST API because of how we implement several
REST patterns, such as:

* One URL per resource
* Clean URL schemes
* Using hypertext to link resources together
* Traversing links instead of hard-coding addresses
* Using a CRUD (Create Retrieve Update Delete) model, using
POST/GET/PUT/DELETE.
* Using mimetypes appropriately for requests and responses
* Many more things.

A proper application using the Review Board API should only ever know about
one single address, which is the root /api/ on the server. It should never
know about other addresses. What it *should* know are the names of links to
follow to get where it wants, and what operations to use on those
resources. So for creating a review request, you would:

1) Get "/api/" (only pre-known URL)
2) Find the "review-requests" link, and follow it.
3) Do a HTTP POST with the appropriate payload.
4) Handle the result, possibly navigating to the link shown for the review
request resource and doing something there.

post-review is actually a bad citizen here, because it does hard-code the
URLs. This comes from a time before we had a REST API. It was merely
"RESTful," which means it incorporates some of the aspects of REST, but not
all. The rewrite with the aforementioned Python API will address this.

So as of now, there's nothing to import from RBTools. That would be the new
API.

Now, you mentioned the requests library and Slumber. The requests library
is just an HTTP access library, much like Python's urllib2 (but much nicer
to use). Regardless of what you end up using, you'll need to make HTTP
requests. However, iirc, requests has some limitations that fail to work
with Review Board. The primary one being that, like urllib2 by default,
your Basic HTTP Auth headers will only be sent upon request, not up-front.
This is bad, as you'll access some resource in our API after having set a
login/password, and expect to get the right data back, but you may not.

I don't know if requests has fixed this, but it was a blocker when I last
looked into it. If you look in post-review, you'll see we had to do some
things to urllib2 to inject the header up-front. You can probably do that
with requests as well. Ignore their Basic HTTP Auth handling and just set
the headers yourself for all the HTTP requests.

Slumber, on the other hand, is not worth pursuing for Review Board. Slumber
is NOT a module for REST. It knows nothing about following links (which are
not a standardized thing anyway). What it is is a nifty little URL builder
that turns statements into URLs. Totally fine if you're just accessing
something with clean URLs, but it won't help you in any way with Review
Board. You'll lose all the benefits of Slumber and gain next to nothing.

Christian

-- 
Christian Hammond - chip...@chipx86.com
Review Board - http://www.reviewboard.org
VMware, Inc. - http://www.vmware.com


On Wed, Apr 18, 2012 at 6:41 PM, Dado Feigenblatt <d...@dado.org> wrote:

> Actually, I'm writing this application in Python.
> Unfortunately we can't wait for the new Python API.
> I wish. I'm not very proficient on REST design patterns.
>
> I guess I might have made two wrong assumptions.
> One that rbtools didn't use REST, and the other that I couldn't import it.
> Now I now it does use REST, but can I import it into my own application?
> What about other modules within rbtools?
>
> Otherwise it seems I'll be using 'requests' to handle REST
> http://docs.python-requests.**org/en/latest<http://docs.python-requests.org/en/latest>
> Slumber (http://slumber.in/) looks like an interesting OOP layer on top
> of that, but RB's hyphenated resource names (i.e. review-requests) don't
> lend themselves to it as they can't be converted into object attributes.
> In slumber one would do
>   api.review-requests.get()
> but that's not valid Python.
>
> What I'm trying to do is to add RB to our software management and
> deployment application.
> It already talks to Perforce.
> We want it to also talk to Review Board so we can tie all together.
> At this point the functionality requirements are pretty basic.
> Initially we only need to be able to create the review request from our
> tool and save its id in our own DB.
> Then we'll want to condition releases to approval statuses, locate all
> reviews for a particular file, that sort of thing.
>
> Thanks,
> Dado
>
>
>
> On Wed, 18 Apr 2012 16:58:27 -0700, Christian Hammond <chip...@chipx86.com>
> wrote:
>
>> Hi Dado,
>>
>> Given your goal of creating review requests, I'd suggest looking at
>> post-review (part of our RBTools package), as that's basically its
>> primary purpose.
>>
>> We are working on a set of actual Python bindings to interface with
>> Review Board, which should make life easier (if you can use Python for
>> your work), but it's unfortunately not anywhere near ready yet.
>>
>> Can you say what you're building and what capabilities you're looking
>> to use?
>>
>> Christian
>>
>> --
>> Christian Hammond - chip...@chipx86.com [1]
>> Review Board - http://www.reviewboard.org [2]
>>  VMware, Inc. - http://www.vmware.com [3]
>>
>> On Wed, Apr 18, 2012 at 3:45 PM, Dado Feigenblatt  wrote:
>>
>>  Hi,
>>
>>  I'm kind of new to REST.
>>  I get the gist of the API.
>>  Since I'm starting an application from scratch, I was wondering if
>> there are any examples I could use for design reference.
>>  Bonus points if it deals with creating requests.
>>  Is there any such thing?
>>
>>  Thanks,
>>  Dado
>>
>>  --
>>  Want to help the Review Board project? Donate today at
>> http://www.reviewboard.org/**donate/ <http://www.reviewboard.org/donate/>[5]
>>  Happy user? Let us know at 
>> http://www.reviewboard.org/**users/<http://www.reviewboard.org/users/>[6]
>>
>>  -~----------~----~----~----~--**----~----~------~--~---
>>  To unsubscribe from this group, send email to
>> reviewboard+unsubscribe@**googlegroups.com<reviewboard%2bunsubscr...@googlegroups.com>[7]
>>
>>  For more options, visit this group at
>> http://groups.google.com/**group/reviewboard?hl=en<http://groups.google.com/group/reviewboard?hl=en>[8]
>>
>>
>>  --
>>  Want to help the Review Board project? Donate today at
>> http://www.reviewboard.org/**donate/ <http://www.reviewboard.org/donate/>[9]
>>  Happy user? Let us know at 
>> http://www.reviewboard.org/**users/<http://www.reviewboard.org/users/>[10]
>>
>>  -~----------~----~----~----~--**----~----~------~--~---
>>  To unsubscribe from this group, send email to
>> reviewboard+unsubscribe@**googlegroups.com<reviewboard%2bunsubscr...@googlegroups.com>
>>  For more options, visit this group at
>> http://groups.google.com/**group/reviewboard?hl=en<http://groups.google.com/group/reviewboard?hl=en>[11]
>>
>> Links:
>> ------
>> [1] mailto:chip...@chipx86.com
>> [2] http://www.reviewboard.org
>> [3] http://www.vmware.com
>> [4] mailto:d...@dado.org
>> [5] http://www.reviewboard.org/**donate/<http://www.reviewboard.org/donate/>
>> [6] http://www.reviewboard.org/**users/<http://www.reviewboard.org/users/>
>> [7] 
>> mailto:reviewboard%**2bunsubscr...@googlegroups.com<reviewboard%252bunsubscr...@googlegroups.com>
>> [8] 
>> http://groups.google.com/**group/reviewboard?hl=en<http://groups.google.com/group/reviewboard?hl=en>
>> [9] http://www.reviewboard.org/**donate/<http://www.reviewboard.org/donate/>
>> [10] http://www.reviewboard.org/**users/<http://www.reviewboard.org/users/>
>> [11] 
>> http://groups.google.com/**group/reviewboard?hl=en<http://groups.google.com/group/reviewboard?hl=en>
>>
>
> --
> Want to help the Review Board project? Donate today at
> http://www.reviewboard.org/**donate/ <http://www.reviewboard.org/donate/>
> Happy user? Let us know at 
> http://www.reviewboard.org/**users/<http://www.reviewboard.org/users/>
> -~----------~----~----~----~--**----~----~------~--~---
> To unsubscribe from this group, send email to reviewboard+unsubscribe@**
> googlegroups.com <reviewboard%2bunsubscr...@googlegroups.com>
> For more options, visit this group at http://groups.google.com/**
> group/reviewboard?hl=en <http://groups.google.com/group/reviewboard?hl=en>
>

-- 
Want to help the Review Board project? Donate today at 
http://www.reviewboard.org/donate/
Happy user? Let us know at http://www.reviewboard.org/users/
-~----------~----~----~----~------~----~------~--~---
To unsubscribe from this group, send email to 
reviewboard+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/reviewboard?hl=en

Reply via email to