514
514
raise NoSuchShare()
517
518
def asAccessibleTo(role, query):
520
Return an iterable which yields the shared proxies that are available to
521
the given role, from the given query.
519
523
@param role: The role to retrieve L{SharedProxy}s for.
521
525
@param query: An Axiom query describing the Items to retrieve, which this
527
@type query: an L{iaxiom.IQuery} provider.
524
if query.comparison is not None:
525
#XXX fix axiom to not break if an AND branch is None?
526
comparison = AND(Share.sharedItem == query.tableClass.storeID,
527
Share.sharedTo.oneOf(role.allRoles()),
530
comparison = AND(Share.sharedItem == query.tableClass.storeID,
531
Share.sharedTo.oneOf(role.allRoles()))
529
allRoles = list(role.allRoles())
531
unlimited = query.cloneQuery(limit=None)
532
for result in unlimited:
533
allShares = list(query.store.query(
535
AND(Share.sharedItem == result,
536
Share.sharedTo.oneOf(allRoles))))
538
for share in allShares:
539
interfaces += share.sharedInterfaces
542
yield SharedProxy(result, interfaces, allShares[0].shareID)
543
if count == query.limit:
538
for resultingShare in (query.store.query(
541
sort=(query.sort, Share.sharedItem.ascending),
545
thisItem = resultingShare.sharedItem
546
thisID = resultingShare.shareID
547
if (lastItem == thisItem) and (thisID == lastID):
548
interfaceSpec += resultingShare.sharedInterfaces
550
if lastItem is not None:
552
yield SharedProxy(lastItem, interfaceSpec, lastID)
553
interfaceSpec = resultingShare.sharedInterfaces[:]
556
if lastItem is not None:
557
yield SharedProxy(lastItem, interfaceSpec, lastID)
560
548
def itemFromProxy(obj):