flask_taxonomies/api.py
def create_term(self, ti: TermIdentification, extra_data=None, session=None):
        """Creates a taxonomy term identified by term identification
        """
        ti = _coerce_ti(ti)
        session = session or self.session
        with session.begin_nested():
            parent_identification = ti.parent_identification()
            if parent_identification:
                parent = parent_identification.term_query(session).one()
                if parent.status != TermStatusEnum.alive:
                    raise TaxonomyError('Can not create term inside inactive parent')
            else:
                parent = None

            slug = self._slugify(parent.slug if parent else None, ti.leaf_slug)
            taxonomy = ti.get_taxonomy(session)
            before_taxonomy_term_created.send(taxonomy, slug=slug, extra_data=extra_data)

            parent = TaxonomyTerm(slug=slug,
                                  extra_data=extra_data,
                                  level=(parent.level + 1) if parent else 0,
                                  parent_id=parent.id if parent else None,
                                  taxonomy_id=taxonomy.id,
                                  taxonomy_code=taxonomy.code)
            session.add(parent)
            after_taxonomy_term_created.send(parent, taxonomy=taxonomy, term=parent)
            return parent
Creates a taxonomy term identified by term identification
        
Creates a taxonomy term identified by term identification
Creates a taxonomy term identified by term identification
def create_term(self, ti: TermIdentification, extra_data=None, session=None):
        ti = _coerce_ti(ti)
        session = session or self.session
        with session.begin_nested():
            parent_identification = ti.parent_identification()
            if parent_identification:
                parent = parent_identification.term_query(session).one()
                if parent.status != TermStatusEnum.alive:
                    raise TaxonomyError('Can not create term inside inactive parent')
            else:
                parent = None
            slug = self._slugify(parent.slug if parent else None, ti.leaf_slug)
            taxonomy = ti.get_taxonomy(session)
            before_taxonomy_term_created.send(taxonomy, slug=slug, extra_data=extra_data)
            parent = TaxonomyTerm(slug=slug,
                                  extra_data=extra_data,
                                  level=(parent.level + 1) if parent else 0,
                                  parent_id=parent.id if parent else None,
                                  taxonomy_id=taxonomy.id,
                                  taxonomy_code=taxonomy.code)
            session.add(parent)
            after_taxonomy_term_created.send(parent, taxonomy=taxonomy, term=parent)
            return parent
def create_term ( self , ti : TermIdentification , extra_data = None , session = None ) : ti = _coerce_ti ( ti ) session = session or self . session with session . begin_nested ( ) : parent_identification = ti . parent_identification ( ) if parent_identification : parent = parent_identification . term_query ( session ) . one ( ) if parent . status != TermStatusEnum . alive : raise TaxonomyError ( 'Can not create term inside inactive parent' ) else : parent = None slug = self . _slugify ( parent . slug if parent else None , ti . leaf_slug ) taxonomy = ti . get_taxonomy ( session ) before_taxonomy_term_created . send ( taxonomy , slug = slug , extra_data = extra_data ) parent = TaxonomyTerm ( slug = slug , extra_data = extra_data , level = ( parent . level + 1 ) if parent else 0 , parent_id = parent . id if parent else None , taxonomy_id = taxonomy . id , taxonomy_code = taxonomy . code ) session . add ( parent ) after_taxonomy_term_created . send ( parent , taxonomy = taxonomy , term = parent ) return parent
Creates a taxonomy term identified by term identification
Creates a taxonomy term identified by term identification
"""Creates a taxonomy term identified by term identification
        """
self
ti
TermIdentification
extra_data
session