[PATCH 2/3] xmlrpc: Export the "to_series" method in patch objects

Doug Anderson dianders at chromium.org
Sun Dec 30 17:00:26 EST 2012


A follow-on CL will add support in pwclient to call this XMLRPC method
to allow listing all of the patches in a series.

Signed-off-by: Doug Anderson <dianders at chromium.org>
---
 apps/patchwork/views/xmlrpc.py |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/apps/patchwork/views/xmlrpc.py b/apps/patchwork/views/xmlrpc.py
index a69c858..36ed605 100644
--- a/apps/patchwork/views/xmlrpc.py
+++ b/apps/patchwork/views/xmlrpc.py
@@ -419,6 +419,28 @@ def patch_set(user, patch_id, params):
         raise
 
 @xmlrpc_method(False)
+def patch_to_series(patch_id):
+    """Take a patch ID and return a list of patches in the same series.
+
+    This uses some heuristics to do its job so might not be perfect.
+    See the function in the Patch model for details.
+
+    @patch_id: The patch ID that's part of the series.
+    @return: A list of patches in the series.
+    """
+    # Get the patch.
+    patch = Patch.objects.filter(id=patch_id)
+    if not patch:
+        return []
+    patch = patch[0]
+
+    # Make a series.
+    patches = patch.to_series()
+
+    # Convert to dict for xmlrpc.
+    return [patch_to_dict(p) for p in patches]
+
+ at xmlrpc_method(False)
 def state_list(search_str="", max_count=0):
     """Get a list of state structures matching the given search string."""
     try:
-- 
1.7.7.3



More information about the Patchwork mailing list