def doWork(self): """ Delete all the corresponding homes, then the ancillary data. """ oldhome = yield self.transaction.calendarHomeWithUID(self.ownerUID, status=_HOME_STATUS_DISABLED) if oldhome is not None: # Work items - we need to clean these up before the home goes away because we have an "on delete cascade" on the WorkItem # table, and if that ran it would leave orphaned Job rows set to a pause state and those would remain for ever in the table. for workType in allScheduleWork: items = yield workType.query(self.transaction, workType.homeResourceID == oldhome.id()) for item in items: yield item.remove() yield oldhome.purgeAll() oldnotifications = yield self.transaction.notificationsWithUID(self.ownerUID, status=_HOME_STATUS_DISABLED) if oldnotifications is not None: yield oldnotifications.purge() # These are things that reference the home id or the user UID but don't get removed via a cascade # iMIP tokens cuaddr = "urn:x-uid:{}".format(self.ownerUID) yield iMIPTokenRecord.deletesome( self.transaction, iMIPTokenRecord.organizer == cuaddr, ) # Delegators - individual and group yield DelegateRecord.deletesome(self.transaction, DelegateRecord.delegator == self.ownerUID) yield DelegateGroupsRecord.deletesome(self.transaction, DelegateGroupsRecord.delegator == self.ownerUID) yield ExternalDelegateGroupsRecord.deletesome(self.transaction, ExternalDelegateGroupsRecord.delegator == self.ownerUID)
def doWork(self): """ Delete all the corresponding homes, then the ancillary data. """ oldhome = yield self.transaction.calendarHomeWithUID( self.ownerUID, status=_HOME_STATUS_DISABLED) if oldhome is not None: # Work items - we need to clean these up before the home goes away because we have an "on delete cascade" on the WorkItem # table, and if that ran it would leave orphaned Job rows set to a pause state and those would remain for ever in the table. for workType in allScheduleWork: items = yield workType.query( self.transaction, workType.homeResourceID == oldhome.id()) for item in items: yield item.remove() yield oldhome.purgeAll() oldnotifications = yield self.transaction.notificationsWithUID( self.ownerUID, status=_HOME_STATUS_DISABLED) if oldnotifications is not None: yield oldnotifications.purge() # These are things that reference the home id or the user UID but don't get removed via a cascade # iMIP tokens cuaddr = "urn:x-uid:{}".format(self.ownerUID) yield iMIPTokenRecord.deletesome( self.transaction, iMIPTokenRecord.organizer == cuaddr, ) # Delegators - individual and group yield DelegateRecord.deletesome( self.transaction, DelegateRecord.delegator == self.ownerUID) yield DelegateGroupsRecord.deletesome( self.transaction, DelegateGroupsRecord.delegator == self.ownerUID) yield ExternalDelegateGroupsRecord.deletesome( self.transaction, ExternalDelegateGroupsRecord.delegator == self.ownerUID)