paramètre 'sort' à getObjectIdsWithCriteria
This commit is contained in:
parent
8b7f1f0b5d
commit
127f7a8d91
|
@ -1170,13 +1170,13 @@ class ObjectsProxy(ObjectsCommonMixin, AdministrableProxyMixin, Proxy):
|
|||
return result
|
||||
|
||||
|
||||
def getObjectIdsWithCriteria(self, criteria, serverId = None):
|
||||
def getObjectIdsWithCriteria(self, criteria, sort = '', serverId = None):
|
||||
userToken = context.getVar('userToken', default = '')
|
||||
serverId = self.getServerId(serverId = serverId)
|
||||
return callServer(
|
||||
serverId,
|
||||
'getObjectIdsWithCriteria',
|
||||
[serverId, getApplicationToken(), userToken, criteria])
|
||||
[serverId, getApplicationToken(), userToken, criteria, sort])
|
||||
|
||||
def getObjectLabelAndLanguage(self, objectId, multiCall = None):
|
||||
"""Retrieve the object label and language in sequence.
|
||||
|
@ -1452,10 +1452,10 @@ class ObjectsProxy(ObjectsCommonMixin, AdministrableProxyMixin, Proxy):
|
|||
objects[objectIds[i]] = lazyObjects[i]()
|
||||
return objects
|
||||
|
||||
def getObjectsWithCriteria(self, criteria, requiredSlotNames = None,
|
||||
serverId = None):
|
||||
def getObjectsWithCriteria(self, criteria, sort = '',
|
||||
requiredSlotNames = None, serverId = None):
|
||||
objectIds = self.getObjectIdsWithCriteria(
|
||||
criteria, serverId = serverId)
|
||||
criteria, sort, serverId = serverId)
|
||||
multiCall = MultiCall()
|
||||
for objectId in objectIds:
|
||||
self.getPartialObject(
|
||||
|
|
|
@ -2292,11 +2292,18 @@ class ObjectsServer(AdministrableServerMixin, Server):
|
|||
result.append(objectId)
|
||||
return result
|
||||
|
||||
def getObjectIdsWithCriteria(self, criteria):
|
||||
def getObjectIdsWithCriteria(self, criteria, sort):
|
||||
virtualServerId = context.getVar('applicationId')
|
||||
virtualServer = self.getVirtualServer(virtualServerId)
|
||||
result = []
|
||||
for objectId, objectCore in virtualServer.objects.items():
|
||||
items = virtualServer.objects.items()
|
||||
if sort:
|
||||
reverse = 0
|
||||
if sort[0] == '-':
|
||||
sort = sort[1:]
|
||||
reverse = 1
|
||||
items.sort(lambda x,y: cmp(getattr(x[1], sort), getattr(y[1], sort)))
|
||||
for objectId, objectCore in items:
|
||||
if not self.canGetObject(objectId):
|
||||
continue
|
||||
try:
|
||||
|
|
Reference in New Issue