changeset 5824:352e78c3b4ab

Allow @fields to include protected properties, document @protected query param.
author John Rouillard <rouilj@ieee.org>
date Sun, 23 Jun 2019 20:00:12 -0400
parents edd9e2c67785
children bcb894bc9740
files doc/rest.txt roundup/rest.py
diffstat 2 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/doc/rest.txt	Sun Jun 23 14:46:05 2019 +0200
+++ b/doc/rest.txt	Sun Jun 23 20:00:12 2019 -0400
@@ -414,8 +414,10 @@
       warnings about this below. Using this for collections is
       discouraged as it is slow and produces a lot of data.
   * - ``@fields=status,title``
-    - will return the ``status``  and ``title`` fields for the issue displayed
-      according to the @verbose parameter
+    - will return the ``status``  and ``title`` fields for the
+      displayed issues. It is added to the fields returned by the
+      @verbose parameter. Protected properties
+      can be included in the list and will be returned.
 
 In addition collections support the ``@fields`` parameter which is a
 colon or comma separated list of fields to embed in the response. For
@@ -642,7 +644,13 @@
 returned. You can limit this by using the ``@fields`` query parameter
 similar to how it is used in collections. This way you can only return
 the fields you are interested in reducing network load as well as
-memory and parsing time on the client side.
+memory and parsing time on the client side. By default protected
+properties (read only in the database) are not listed. Th
+is makes it easier to submit the attributes from a
+``@verbose=0`` query using PUT. To include protected properties
+in the output og a GET add the query parameter
+``@protected=true`` to the query and attributes like: actor,
+created, creator and activity will be include in the result.
 
 Link and Multilink properties are displayed as a dictionary with a
 ``link`` and an ``id`` property by default. This is controlled by the
--- a/roundup/rest.py	Sun Jun 23 14:46:05 2019 +0200
+++ b/roundup/rest.py	Sun Jun 23 20:00:12 2019 -0400
@@ -656,9 +656,10 @@
                 f = value.split(",")
                 if len(f) == 1:
                     f=value.split(":")
+                allprops=class_obj.getprops(protected=True)
                 for i in f:
                     try:
-                        display_props[i] = class_obj.properties[i]
+                        display_props[i] = allprops[i]
                     except KeyError as err:
                         raise UsageError("Failed to find property '%s' "
                                          "for class %s."%(i, class_name))
@@ -821,9 +822,10 @@
                 f=value.split(",")
                 if len(f) == 1:
                     f=value.split(":")
+                allprops=class_obj.getprops(protected=True)
                 for i in f:
                     try:
-                        props[i] = class_obj.properties[i]
+                        props[i] = allprops[i]
                     except KeyError as err:
                         raise UsageError("Failed to find property '%s' for class %s."%(i, class_name))
             elif key == "@protected":

Roundup Issue Tracker: http://roundup-tracker.org/