def destroySelf(self): store = IStore(Packageset) sources = store.find(PackagesetSources, PackagesetSources.packageset == self) sources.remove() store.remove(self) if self.relatedSets().is_empty(): store.remove(self.packagesetgroup)
def destroySelf(self): store = IStore(Packageset) sources = store.find( PackagesetSources, PackagesetSources.packageset == self) sources.remove() store.remove(self) if self.relatedSets().is_empty(): store.remove(self.packagesetgroup)
def removeDeviceClass(self, main_class, sub_class=None): """See `IHWDevice.`""" store = IStore(HWDeviceClass) result_set = store.find( HWDeviceClass, HWDeviceClass.device == self.id, HWDeviceClass.main_class == main_class, HWDeviceClass.sub_class == sub_class) existing_record = result_set.one() if existing_record is not None: store.remove(existing_record)
def removeDeviceClass(self, main_class, sub_class=None): """See `IHWDevice.`""" store = IStore(HWDeviceClass) result_set = store.find( HWDeviceClass, HWDeviceClass.device == self.id, HWDeviceClass.main_class == main_class, HWDeviceClass.sub_class == sub_class, ) existing_record = result_set.one() if existing_record is not None: store.remove(existing_record)
def _set_tags(self, tags): """Update the tags to filter on. The tags can be qualified with a leading hyphen, and can be bundled in any iterable. If they are passed within a `searchbuilder.any` or `searchbuilder.all` object, the `find_all_tags` attribute will be updated to match. Wildcard tags - `*` and `-*` - can be given too, and will update `include_any_tags` and `exclude_any_tags`. """ # Deal with searchbuilder terms. if isinstance(tags, searchbuilder.all): self.find_all_tags = True tags = frozenset(tags.query_values) elif isinstance(tags, searchbuilder.any): self.find_all_tags = False tags = frozenset(tags.query_values) else: # Leave find_all_tags unchanged. tags = frozenset(tags) wildcards = frozenset((u"*", u"-*")).intersection(tags) # Set wildcards. self.include_any_tags = "*" in wildcards self.exclude_any_tags = "-*" in wildcards # Deal with other tags. tags = tags - wildcards store = IStore(BugSubscriptionFilterTag) current_tag_filters = dict( (tag_filter.qualified_tag, tag_filter) for tag_filter in store.find( BugSubscriptionFilterTag, BugSubscriptionFilterTag.filter == self)) # Remove unused tags. for tag in set(current_tag_filters).difference(tags): tag_filter = current_tag_filters.pop(tag) store.remove(tag_filter) # Add additional tags. for tag in tags.difference(current_tag_filters): tag_filter = BugSubscriptionFilterTag() tag_filter.filter = self tag_filter.include = not tag.startswith("-") tag_filter.tag = tag.lstrip("-") store.add(tag_filter)
def _set_tags(self, tags): """Update the tags to filter on. The tags can be qualified with a leading hyphen, and can be bundled in any iterable. If they are passed within a `searchbuilder.any` or `searchbuilder.all` object, the `find_all_tags` attribute will be updated to match. Wildcard tags - `*` and `-*` - can be given too, and will update `include_any_tags` and `exclude_any_tags`. """ # Deal with searchbuilder terms. if isinstance(tags, searchbuilder.all): self.find_all_tags = True tags = frozenset(tags.query_values) elif isinstance(tags, searchbuilder.any): self.find_all_tags = False tags = frozenset(tags.query_values) else: # Leave find_all_tags unchanged. tags = frozenset(tags) wildcards = frozenset((u"*", u"-*")).intersection(tags) # Set wildcards. self.include_any_tags = "*" in wildcards self.exclude_any_tags = "-*" in wildcards # Deal with other tags. tags = tags - wildcards store = IStore(BugSubscriptionFilterTag) current_tag_filters = dict( (tag_filter.qualified_tag, tag_filter) for tag_filter in store.find( BugSubscriptionFilterTag, BugSubscriptionFilterTag.filter == self)) # Remove unused tags. for tag in set(current_tag_filters).difference(tags): tag_filter = current_tag_filters.pop(tag) store.remove(tag_filter) # Add additional tags. for tag in tags.difference(current_tag_filters): tag_filter = BugSubscriptionFilterTag() tag_filter.filter = self tag_filter.include = not tag.startswith("-") tag_filter.tag = tag.lstrip("-") store.add(tag_filter)