Changeset 32fdc4a in flexoentity


Ignore:
Timestamp:
11/20/25 11:41:36 (8 weeks ago)
Author:
Enrico Schwass <ennoausberlin@…>
Branches:
master
Children:
fd1913f
Parents:
d0a379f
Message:

enforce domain creation rules

Location:
flexoentity
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • flexoentity/domain_manager.py

    rd0a379f r32fdc4a  
    7676        return cls.register(domain)
    7777
    78     @classmethod
    79     def get_or_create(cls, code: str, **kwargs) -> Domain:
    80         """Return existing domain or create+register new one."""
    81         if code in cls._by_code:
    82             return cls._by_code[code]
    83         return cls.create(code, **kwargs)
    84 
    8578    # ---------------------------------------------------------------
    8679    # Utility
  • flexoentity/flexo_entity.py

    rd0a379f r32fdc4a  
    214214                                 description=kwargs.get("description", ""))
    215215        else:
    216             DomainManager.get_or_create(domain_id=domain_id, **kwargs)
     216            # require that this domain already exists
     217            if domain_id not in DomainManager.all_domain_ids():
     218                raise ValueError(
     219                    f"Domain '{domain_id}' does not exist. "
     220                    f"Create it first via Domain.with_domain_id(...)."
     221                )
    217222
    218223        flexo_id = FlexOID.safe_generate(
Note: See TracChangeset for help on using the changeset viewer.