def add_tag_by_name(self, tag_name, vocab=None, autoflush=True): """Add a tag with the given name to this package's tags. By default the given tag_name will be searched for among the free tags (tags which do not belong to any vocabulary) only. If the optional argument `vocab` is given then the named vocab will be searched for the tag name instead. If no tag with the given name is found, one will be created. If the optional argument vocab is given and there is no tag with the given name in the given vocabulary, then a new tag will be created and added to the vocabulary. """ from tag import Tag if not tag_name: return # Get the named tag. tag = Tag.by_name(tag_name, vocab=vocab, autoflush=autoflush) if not tag: # Tag doesn't exist yet, make a new one. if vocab: tag = Tag(name=tag_name, vocabulary_id=vocab.id) else: tag = Tag(name=tag_name) assert tag is not None self.add_tag(tag)
def add_tag_by_name(self, tag_name, vocab=None, autoflush=True): """Add a tag with the given name to this package's tags. By default the given tag_name will be searched for among the free tags (tags which do not belong to any vocabulary) only. If the optional argument `vocab` is given then the named vocab will be searched for the tag name instead. If no tag with the given name is found, one will be created. If the optional argument vocab is given and there is no tag with the given name in the given vocabulary, then a new tag will be created and added to the vocabulary. """ from tag import Tag if not tag_name: return # Get the named tag. tag = Tag.by_name(tag_name, vocab=vocab, autoflush=autoflush) if not tag: # Tag doesn't exist yet, make a new one. if vocab: tag = Tag(name=tag_name, vocabulary_id=vocab.id) else: tag = Tag(name=tag_name) assert tag is not None self.add_tag(tag)
def add_tag_by_name(self, tagname, autoflush=True): from tag import Tag if not tagname: return tag = Tag.by_name(tagname, autoflush=autoflush) if not tag: tag = Tag(name=tagname) if not tag in self.tags: self.tags.append(tag)
def add_tag_by_name(self, tagname, autoflush=True): from tag import Tag if not tagname: return tag = Tag.by_name(tagname, autoflush=autoflush) if not tag: tag = Tag(name=tagname) if not tag in self.tags: self.tags.append(tag)