Commit 44c96349 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: use portal_catalog to be complaint with listbox pagination

   Call catalog on the uids for compute properly the list of objects to list (pagination + sort).

    Remarrk: This change isn't ideal and introduce an extra catalog call, but this only adds few microseconds (>10ms) to the return.
parent 94999b09
# This script might not be efficient to a large quantities of # This script might not be efficient to a large quantities of
# Compute Nodes # Compute Nodes
portal = context.getPortalObject()
from DateTime import DateTime
kw = {"node_uid": context.getUid(),
"at_date": DateTime()}
def filter_per_portal_type(document): def filter_per_portal_type(document):
if document.getPortalType() == "Compute Node" \ if document.getPortalType() == "Compute Node" \
...@@ -17,6 +13,7 @@ def filter_per_portal_type(document): ...@@ -17,6 +13,7 @@ def filter_per_portal_type(document):
and document.getValidationState() == "validated": and document.getValidationState() == "validated":
return document return document
return [ i.getObject() return portal.portal_catalog(uid=[i.uid
for i in context.portal_simulation.getCurrentTrackingList(**kw) for i in context.portal_simulation.getCurrentTrackingList(
if filter_per_portal_type(i.getObject())] node_uid=context.getUid(), at_date=DateTime())
if filter_per_portal_type(i.getObject())], **kw)
# This script might not be efficient to a large quantities of # This script might not be efficient to a large quantities of
# Compute Nodes # Compute Nodes
from DateTime import DateTime portal = context.getPortalObject()
kw = {"project_uid": context.getUid(),
"at_date": DateTime()}
def filter_per_portal_type(document): def filter_per_portal_type(document):
if document.getPortalType() == "Compute Node" \ if document.getPortalType() == "Compute Node" \
...@@ -16,6 +13,7 @@ def filter_per_portal_type(document): ...@@ -16,6 +13,7 @@ def filter_per_portal_type(document):
and document.getValidationState() == "validated": and document.getValidationState() == "validated":
return document return document
return [ i.getObject() return portal.portal_catalog(uid=[i.uid
for i in context.portal_simulation.getCurrentTrackingList(**kw) for i in context.portal_simulation.getCurrentTrackingList(
if filter_per_portal_type(i.getObject())] project_uid=context.getUid(), at_date=DateTime())
if filter_per_portal_type(i.getObject())], **kw)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment