changeset 8563:909cf30c01c1

doc: rename input in examples to input_payload the variable input shadows the built-in function input().
author John Rouillard <rouilj@ieee.org>
date Wed, 08 Apr 2026 22:20:06 -0400
parents 9c3ec0a5c7fc
children 13732c1d8392
files doc/rest.txt
diffstat 1 files changed, 22 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/doc/rest.txt	Wed Apr 08 21:39:40 2026 -0400
+++ b/doc/rest.txt	Wed Apr 08 22:20:06 2026 -0400
@@ -1899,7 +1899,7 @@
 
         @Routing.route("/summary2")
         @_data_decorator
-        def summary2(self, input):
+        def summary2(self, input_payload):
             result = { "hello": "world" }
             return 200, result
 
@@ -1916,7 +1916,7 @@
 
     # handle more endpoints
         @Routing.route("/data/<:class_name>/@schema", 'GET')
-        def get_element_schema(self, class_name, input):
+        def get_element_schema(self, class_name, input_payload):
             result = { "schema": {} }
             uid = self.db.getuid ()
             if not self.db.security.hasPermission('View', uid, class_name) :
@@ -1966,7 +1966,7 @@
 
     @Routing.route("/summary")
     @_data_decorator
-    def summary2(self, input):
+    def summary2(self, input_payload):
         result = { "hello": "world" }
         return 200, result
 
@@ -1983,7 +1983,7 @@
 endpoints to new locations. Adding::
 
     @Routing.route("/data2/<:classname>")
-    def get_collection2(self, classname, input):
+    def get_collection2(self, classname, input_payload):
         """ Remap existing function in rest.py to a new endpoint
 
             Existing function is decorated with:
@@ -1994,7 +1994,7 @@
             so we need to drop @_data_decorator from this function since
             we can't apply @_data_decorator twice.
         """
-        return self.get_collection(classname, input)
+        return self.get_collection(classname, input_payload)
 
 will make the response at /rest/data2/<class> be the same as what is
 normally at /rest/data/<class>.
@@ -2031,7 +2031,7 @@
     class RestfulInstance(object):
 
         @Routing.route("/data/@permission/Developer")
-        def get_role_Developer(self, input):
+        def get_role_Developer(self, input_payload):
             '''An endpoint to return a list of users with Developer
                role who can be assigned to an issue.
 
@@ -2072,14 +2072,14 @@
                 # deny all other url parmeters
                 return False
 
-            # Cleanup input.list to prevent user from probing roles
+            # Cleanup input_payload.list to prevent user from probing roles
             # or viewing things the user should not be able to view.
-            input.list[:] = [ fs for fs in input.list
-                              if allowed_field(fs) ]
+            input_payload.list[:] = [ fs for fs in input_payload.list
+                                      if allowed_field(fs) ]
 
             # Add the role filter required to implement the permission
             # search
-            input.list.append(MiniFieldStorage("roles", "Developer"))
+            input_payload.list.append(MiniFieldStorage("roles", "Developer"))
 
             # change user to acquire permission to search roles
             self.db.setCurrentUser('admin')
@@ -2087,7 +2087,7 @@
             # Once we have cleaned up the request, pass it to
             # get_collection as though /rest/data/users?... has been called
             # to get @verbose and other args supported.
-            return self.get_collection('user', input)
+            return self.get_collection('user', input_payload)
 
 Calling this with::
 
@@ -2210,7 +2210,7 @@
     class RestfulInstance(object):
         @Routing.route("/jwt/issue", 'POST')
         @_data_decorator
-        def generate_jwt(self, input):
+        def generate_jwt(self, input_payload):
         """Create a JSON Web Token (jwt)
         """
             import datetime
@@ -2237,7 +2237,7 @@
                 raise Unauthorised(denialmsg)
 
             # verify we have input data.
-            if not input:
+            if not input_payload:
                 raise UsageError("Missing data payload. "
                              "Verify Content-Type is sent")
 
@@ -2257,13 +2257,13 @@
                    }
 
             lifetime = 0
-            if 'lifetime' in input:
-                if input['lifetime'].value != 'unlimited':
+            if 'lifetime' in input_payload:
+                if input_payload['lifetime'].value != 'unlimited':
                     try:
-                        lifetime = datetime.timedelta(seconds=int(input['lifetime'].value))
+                        lifetime = datetime.timedelta(seconds=int(input_payload['lifetime'].value))
                     except ValueError:
                         raise UsageError("Value 'lifetime' must be 'unlimited' or an integer to specify" +
-                                         " lifetime in seconds. Got %s."%input['lifetime'].value)
+                                         " lifetime in seconds. Got %s."%input_payload['lifetime'].value)
             else:
                 lifetime = datetime.timedelta(seconds=86400) # 1 day by default
 
@@ -2271,8 +2271,8 @@
                 claim['exp'] = utcnow() + lifetime
 
             newroles = []
-            if 'roles' in input:
-                for role in [ r.lower() for r in input['roles'].value ]:
+            if 'roles' in input_payload:
+                for role in [ r.lower() for r in input_payload['roles'].value ]:
                     if role not in rolenames:
                         raise UsageError("Role %s is not valid."%role)
                     if role in user_roles:
@@ -2302,12 +2302,12 @@
 
         @Routing.route("/jwt/validate", 'GET')
         @_data_decorator
-        def validate_jwt(self,input):
+        def validate_jwt(self,input_payload):
             import jwt
-            if not 'jwt' in input:
+            if not 'jwt' in input_payload:
                 raise UsageError("jwt key must be specified")
 
-            myjwt = input['jwt'].value
+            myjwt = input_payload['jwt'].value
 
             secret = self.db.config.WEB_JWT_SECRET[0]
 

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