From e045483500bab538db29134c327c58ab8b8390d6 Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Thu, 21 Jul 2022 21:14:56 +0000 Subject: [PATCH] Fix pecan lookup_controller DeprecationWarning This patch updates Designate for the new funtion signature on pecan lookup_controller to include the request information if available. This corrects the following warning we were seeing in Designate: DeprecationWarning: The function signature for pecan.routing.lookup_controller is changing in the next version of pecan. Please update to: `lookup_controller(self, obj, remainder, request)`. Change-Id: Icb206e59c83eec984599d48b3d4719c36eb83734 --- designate/api/v2/controllers/rest.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/designate/api/v2/controllers/rest.py b/designate/api/v2/controllers/rest.py index e6de35934..7f6c2c929 100644 --- a/designate/api/v2/controllers/rest.py +++ b/designate/api/v2/controllers/rest.py @@ -62,7 +62,7 @@ class RestController(pecan.rest.RestController): else: return criterion - def _handle_post(self, method, remainder): + def _handle_post(self, method, remainder, request=None): ''' Routes ``POST`` actions to the appropriate controller. ''' @@ -75,7 +75,8 @@ class RestController(pecan.rest.RestController): controller = getattr(self, remainder[0], None) if controller and not inspect.ismethod(controller): - return pecan.routing.lookup_controller(controller, remainder[1:]) + return pecan.routing.lookup_controller(controller, remainder[1:], + request=request) # finally, check for the regular post_one/post requests controller = self._find_controller('post_one', 'post') @@ -84,7 +85,7 @@ class RestController(pecan.rest.RestController): pecan.abort(405) - def _handle_patch(self, method, remainder): + def _handle_patch(self, method, remainder, request=None): ''' Routes ``PATCH`` actions to the appropriate controller. ''' @@ -97,7 +98,8 @@ class RestController(pecan.rest.RestController): controller = getattr(self, remainder[0], None) if controller and not inspect.ismethod(controller): - return pecan.routing.lookup_controller(controller, remainder[1:]) + return pecan.routing.lookup_controller(controller, remainder[1:], + request=request) # finally, check for the regular patch_one/patch requests controller = self._find_controller('patch_one', 'patch') @@ -106,7 +108,7 @@ class RestController(pecan.rest.RestController): pecan.abort(405) - def _handle_put(self, method, remainder): + def _handle_put(self, method, remainder, request=None): ''' Routes ``PUT`` actions to the appropriate controller. ''' @@ -119,7 +121,8 @@ class RestController(pecan.rest.RestController): controller = getattr(self, remainder[0], None) if controller and not inspect.ismethod(controller): - return pecan.routing.lookup_controller(controller, remainder[1:]) + return pecan.routing.lookup_controller(controller, remainder[1:], + request=request) # finally, check for the regular put_one/put requests controller = self._find_controller('put_one', 'put') @@ -128,7 +131,7 @@ class RestController(pecan.rest.RestController): pecan.abort(405) - def _handle_delete(self, method, remainder): + def _handle_delete(self, method, remainder, request=None): ''' Routes ``DELETE`` actions to the appropriate controller. ''' @@ -141,7 +144,8 @@ class RestController(pecan.rest.RestController): controller = getattr(self, remainder[0], None) if controller and not inspect.ismethod(controller): - return pecan.routing.lookup_controller(controller, remainder[1:]) + return pecan.routing.lookup_controller(controller, remainder[1:], + request=request) # finally, check for the regular delete_one/delete requests controller = self._find_controller('delete_one', 'delete')