- Groups:
New python API
Review Request #2508 — Created Aug. 3, 2011 and discarded
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
Description | From | Last Updated |
---|---|---|
This should be automatically provided by Exception. Also, self.message is deprecated in 2.6, so we wouldn't want to use it … |
chipx86 | |
First line in the docs must be one line only. It should be a brief summary. Same with all other … |
chipx86 | |
Not needed. |
chipx86 | |
Two blank lines between these. |
chipx86 | |
Two blank lines between these. |
chipx86 | |
Wouldn't -1 just cause us to return the wrong error? Since it'd get the last entry in the array. I … |
chipx86 | |
You can do this without the inspect module: for name, value in locals(): if value != RequestError and issubclass(value, RequestError): … |
chipx86 | |
Still would rather not have FETCH_RQUEST_METHOD. |
chipx86 | |
"Contains" and "requests" |
chipx86 | |
One line. |
chipx86 | |
"High" |
chipx86 | |
Should use parens instead of \ |
chipx86 | |
All this should probably be put in another branch somewhere, instead of in here. Or it should just be added. … |
chipx86 | |
Same with all these. |
chipx86 | |
This function should be returning something, or it shouldn't be provided at all yet. |
chipx86 | |
Blank line between these. |
chipx86 | |
Blank line between these. |
chipx86 | |
This can all probably be: setattr(resource, '__iter__', lambda: [i for i in lst]) |
chipx86 | |
The parameter should only be indented 4 spaces. |
chipx86 | |
Swap these. variable == value |
chipx86 | |
_iteritems The __ would cause the name to be mangled, making debugging harder. |
chipx86 | |
return [i for i in self._iteritems] |
chipx86 | |
How does this work asynchronously? There's no callback. |
chipx86 | |
Capital D. |
chipx86 | |
Should subclass object. |
chipx86 |
-
-
This should be automatically provided by Exception. Also, self.message is deprecated in 2.6, so we wouldn't want to use it anyway.
-
First line in the docs must be one line only. It should be a brief summary. Same with all other docstrings.
-
-
-
-
Wouldn't -1 just cause us to return the wrong error? Since it'd get the last entry in the array. I imagine this shouldn't default to anything. That way it's totally the caller's fault if specifying an incorrect parameter.
-
You can do this without the inspect module: for name, value in locals(): if value != RequestError and issubclass(value, RequestError): request_errors[value.code] = value
-
-
-
-
-
-
All this should probably be put in another branch somewhere, instead of in here. Or it should just be added. Right now, there's no way of knowing what the reasoning is.
-
-
-
-
-
-
-
-
-
-
-
-
-
- Description:
-
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