From 4938f827722238c237f917fb9617cdff9b6e0c7e Mon Sep 17 00:00:00 2001 From: Peter Hamilton Date: Thu, 8 Aug 2019 16:21:18 -0400 Subject: [PATCH] Sort the Locate matched objects by their creation date This change updates the PyKMIP server's support for the Locate operation, sorting the matched objects found by Locate by their initial date, newest objects first. This matches the KMIP specification's definition for how Locate results should be ordered. --- kmip/services/server/engine.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kmip/services/server/engine.py b/kmip/services/server/engine.py index 98ea104..a64ae4f 100644 --- a/kmip/services/server/engine.py +++ b/kmip/services/server/engine.py @@ -1773,6 +1773,13 @@ class KmipEngine(object): managed_objects = managed_objects_filtered + # Sort the matching results by their creation date. + managed_objects = sorted( + managed_objects, + key=lambda x: x.initial_date, + reverse=True + ) + unique_identifiers = [ str(x.unique_identifier) for x in managed_objects ]