def get_associated_publics(self): sp_uuids = yield self.get_associated_service_profiles() public_ids = utils.flatten([(yield ServiceProfile(uuid).get_public_ids()) for uuid in sp_uuids]) defer.returnValue(public_ids)
def get_associated_publics(self): sp_uuids = yield self.get_associated_service_profiles() public_ids = utils.flatten( [(yield ServiceProfile(uuid).get_public_ids()) for uuid in sp_uuids]) defer.returnValue(public_ids)
def on_forced_expiry(self, private_ids, public_ids=None): # If we weren't given a list of public IDs, look them up from the private IDs. deferreds = [] if not public_ids: # Query the public IDs associated with all public IDs. This is quite intensive # but we don't expect the list of private IDs to be long. deferreds = [self._cache.get_associated_public_ids(id) for id in private_ids] results = yield defer.gatherResults(deferreds, consumeErrors=True) public_ids = utils.flatten(results) # Remove any duplicates. public_ids = list(set(public_ids)) _log.debug("Retrieved public IDs %s" % str(public_ids)) timestamp = self._cache.generate_timestamp() # Delete all the public and private IDs from the cache. Note that technically we # needn't flush private IDs if there are still public IDs remaining. However, it's # simpler (and, given this is a rare operation, not too performance-impacting) just to # flush these too. Note that we specify fireOnOneErrback here to ensure an exception # is thrown if either Deferred fails. yield defer.DeferredList([self._cache.delete_multi_private_ids(private_ids, timestamp=timestamp), self._cache.delete_multi_public_ids(public_ids, timestamp=timestamp)], fireOnOneErrback=True, consumeErrors=True)
def get_public_ids(self): irs_uuids = yield self.get_irses() public_ids = utils.flatten([(yield IRS(uuid).get_associated_publics()) for uuid in irs_uuids]) defer.returnValue(public_ids)