Loading cloudcontrol/common/client/tags.py +35 −0 Original line number Diff line number Diff line Loading @@ -447,6 +447,41 @@ class TagDB(object): # end dict like class ParentWrapper(object): def __init__(self, sub_id, type_, parent): self.sub_id = sub_id self._parent = parent self._parent.add_sub_object(self.sub_id, tuple(), type_) def __del__(self): self._parent.remove_sub_object(self.sub_id) def _not_implemented(self, *args, **kwargs): raise NotImplementedError def add_tags(self, tags): for t in tags: self.add_tag(t) def remove_tags(self, tag_names): for n in tag_names: self.remove_tag(n) def add_tag(self, tag): self._parent.add_sub_tag(self.sub_id, tag) def remove_tag(self, tag_name): self._parent.remove_sub_tag(self.sub_id, tag_name) def __getattr__(self, name): if name in ('add_sub_tag', 'remove_sub_tag', 'add_sub_object', 'remove_sub_object'): return self._not_implemented return getattr(self._parent, name) class RootTagDB(TagDB): """Root tag database. Loading Loading
cloudcontrol/common/client/tags.py +35 −0 Original line number Diff line number Diff line Loading @@ -447,6 +447,41 @@ class TagDB(object): # end dict like class ParentWrapper(object): def __init__(self, sub_id, type_, parent): self.sub_id = sub_id self._parent = parent self._parent.add_sub_object(self.sub_id, tuple(), type_) def __del__(self): self._parent.remove_sub_object(self.sub_id) def _not_implemented(self, *args, **kwargs): raise NotImplementedError def add_tags(self, tags): for t in tags: self.add_tag(t) def remove_tags(self, tag_names): for n in tag_names: self.remove_tag(n) def add_tag(self, tag): self._parent.add_sub_tag(self.sub_id, tag) def remove_tag(self, tag_name): self._parent.remove_sub_tag(self.sub_id, tag_name) def __getattr__(self, name): if name in ('add_sub_tag', 'remove_sub_tag', 'add_sub_object', 'remove_sub_object'): return self._not_implemented return getattr(self._parent, name) class RootTagDB(TagDB): """Root tag database. Loading