accélère la récupération des groupes d'identités
This commit is contained in:
parent
3523769178
commit
232592cd16
|
@ -650,6 +650,28 @@ class IdentitiesServer(commonIdentities.IdentitiesCommonMixin,
|
|||
return newPeerNameIdentifier
|
||||
return None
|
||||
|
||||
def sortObjectIds(self, objectIds, sortRule):
|
||||
# duplicated here since getLabel() is expensive on Identities
|
||||
virtualServerId = context.getVar('applicationId')
|
||||
virtualServer = self.getVirtualServer(virtualServerId)
|
||||
if not objectIds:
|
||||
objectIds = virtualServer.objects.keys()
|
||||
else:
|
||||
objectIds = [x for x in objectIds \
|
||||
if virtualServer.objects.has_key(x)]
|
||||
|
||||
if sortRule == 'id':
|
||||
objectIds.sort(lambda x,y: cmp(
|
||||
int(commonTools.extractLocalId(x)),
|
||||
int(commonTools.extractLocalId(y))) )
|
||||
return objectIds
|
||||
|
||||
labels = [(x, virtualServer.objects[x].getLabel()) for x in objectIds]
|
||||
labels.sort(lambda x,y: cmp(x[1], x[1]))
|
||||
objectIds = [x[0] for x in labels]
|
||||
return objectIds
|
||||
|
||||
|
||||
def vote(self, electionId, voteToken):
|
||||
virtualServerId = context.getVar('applicationId')
|
||||
virtualServer = self.getVirtualServer(virtualServerId)
|
||||
|
|
|
@ -204,6 +204,11 @@ class PeopleServer(PeopleCommonMixin, ObjectsServer):
|
|||
# or objectId == getProxyForServerRole('identities').getPersonId()
|
||||
|
||||
def canGetObject(self, objectId):
|
||||
clientToken = context.getVar('clientToken')
|
||||
clientId = getApplicationId(clientToken)
|
||||
clientRole = commonTools.extractRole(clientId)
|
||||
if clientRole == 'identities':
|
||||
return 1
|
||||
if ObjectsServer.canGetObject(self, objectId):
|
||||
return 1
|
||||
virtualServerId = context.getVar('applicationId')
|
||||
|
|
|
@ -106,14 +106,27 @@ class GroupMixin(objects.ObjectWebMixin):
|
|||
|
||||
|
||||
class GroupCountableMixin(GroupMixin):
|
||||
itemIds = None
|
||||
itemIds_kind_importExport = 'private'
|
||||
itemIds_kind_stateInEditMode = 'read-only'
|
||||
itemIds_kind_itemKind_value_widgetName = 'SelectId'
|
||||
itemIds_kind_itemKind_valueName = 'Id'
|
||||
itemIds_kind_widget_fieldLabel = N_('Items')
|
||||
itemIds_kind_widgetName = 'Multi'
|
||||
itemIds_kindName = 'Sequence'
|
||||
_itemIds = None
|
||||
class itemIds_kindClass:
|
||||
_kindName = 'Sequence'
|
||||
importExport = 'private'
|
||||
stateInEditMode = 'read-only'
|
||||
itemKind_value_widgetName = 'SelectId'
|
||||
itemKind_valueName = 'Id'
|
||||
widget_fieldLabel = N_('Items')
|
||||
widgetName = 'Multi'
|
||||
|
||||
def getter(self, slot):
|
||||
object = slot.getObject()
|
||||
if object._itemIds:
|
||||
return object._itemIds
|
||||
try:
|
||||
itemIds = object.getContainedIds()
|
||||
itemIds = sortIds(itemIds)
|
||||
object._itemIds = itemIds
|
||||
except faults.IllegalRecursiveGroup:
|
||||
itemIds = []
|
||||
return itemIds
|
||||
|
||||
def getEditLayoutSlotNames(self, fields, parentSlot = None):
|
||||
slotNames = GroupMixin.getEditLayoutSlotNames(
|
||||
|
@ -130,7 +143,7 @@ class GroupCountableMixin(GroupMixin):
|
|||
slotNames = slotNames[:]
|
||||
userToken = context.getVar('userToken', default = '')
|
||||
if not userToken or context.getVar('useCompactLayout', default = 0):
|
||||
for slotName in ['membersSet']:
|
||||
for slotName in ['membersSet', 'itemIds']:
|
||||
if slotName in slotNames:
|
||||
slotNames.remove(slotName)
|
||||
return slotNames
|
||||
|
@ -166,14 +179,6 @@ class GroupsWeb(objects.ObjectsWebMixin, proxyGroups.GroupsProxy):
|
|||
object = proxyGroups.GroupsProxy.getObject_handleResult(self,
|
||||
lazyObject)
|
||||
object.className = object.__class__.__name__
|
||||
if hasattr(object, 'itemIds'): # group is countable
|
||||
try:
|
||||
object.itemIds = object.getContainedIds()
|
||||
object.itemIds = sortIds(object.itemIds)
|
||||
except faults.IllegalRecursiveGroup:
|
||||
object.itemIds_kind = commonTools.newThing(
|
||||
'kind', 'String', isTranslatable = 0)
|
||||
object.itemIds = _('Illegal recursive group')
|
||||
return object
|
||||
|
||||
def newObject(self, keywords = None):
|
||||
|
|
Reference in New Issue