From f4ad46acc69be5a713fe7a38ae77c64b4327f9b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sat, 16 Nov 2019 12:18:41 +0100 Subject: [PATCH] storage: allow sorting objects with missing (receipt_)time (#36515) --- wcs/qommon/storage.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wcs/qommon/storage.py b/wcs/qommon/storage.py index ffed5f75f..dc2e6a4af 100644 --- a/wcs/qommon/storage.py +++ b/wcs/qommon/storage.py @@ -290,6 +290,9 @@ class StorableObject(object): # on all systems so we go the cheap and almost ok way. from .misc import simplify key_function = lambda x: simplify(x.name) + elif order_by.endswith('_time'): + typed_none = time.gmtime(-10**10) # 1653 + key_function = lambda x: getattr(x, order_by) or typed_none else: key_function = lambda x: getattr(x, order_by) objects.sort(key=key_function)