diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 29cdac24..686bda71 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,15 @@ Release History =============== +0.7.0 +----- + +* Simplify Container structure and refactor metaclass usage +* Migrate data elements to inherit from `BaseContainer` +* Remove `meta_` fields and use module functions +* Resolve associated classes dynamically and on domain activation +* Remove custom Meta classes and replace with `Options` + 0.6.2 ----- diff --git a/src/protean/adapters/repository/memory.py b/src/protean/adapters/repository/memory.py index bbc2422c..36963e2d 100644 --- a/src/protean/adapters/repository/memory.py +++ b/src/protean/adapters/repository/memory.py @@ -17,7 +17,7 @@ from protean.port.dao import BaseDAO, BaseLookup, ResultSet from protean.port.provider import BaseProvider from protean.utils import Database -from protean.utils.container import auto_fields, id_field, attributes +from protean.utils.container import attributes, auto_fields, id_field from protean.utils.query import Q # Global in-memory store of dict data. Keyed by name, to provide diff --git a/src/protean/core/command.py b/src/protean/core/command.py index 9aebbcee..41db199f 100644 --- a/src/protean/core/command.py +++ b/src/protean/core/command.py @@ -1,7 +1,6 @@ from protean.exceptions import InvalidDataError, ValidationError from protean.utils import DomainObjects, derive_element_class -from protean.utils.container import BaseContainer -from protean.utils.container import OptionsMixin +from protean.utils.container import BaseContainer, OptionsMixin class BaseCommand(BaseContainer, OptionsMixin): diff --git a/src/protean/core/email.py b/src/protean/core/email.py index 8dd9bdbc..21157c3b 100644 --- a/src/protean/core/email.py +++ b/src/protean/core/email.py @@ -6,8 +6,7 @@ convert_str_values_to_list, derive_element_class, ) -from protean.utils.container import BaseContainer -from protean.utils.container import OptionsMixin +from protean.utils.container import BaseContainer, OptionsMixin class BaseEmailProvider: diff --git a/src/protean/core/entity.py b/src/protean/core/entity.py index d6b47036..d75ef410 100644 --- a/src/protean/core/entity.py +++ b/src/protean/core/entity.py @@ -31,12 +31,12 @@ ) from protean.utils.container import ( _FIELDS, + _ID_FIELD_NAME, BaseContainer, OptionsMixin, + attributes, fields, - _ID_FIELD_NAME, id_field, - attributes, ) logger = logging.getLogger("protean.domain.entity") diff --git a/src/protean/core/event.py b/src/protean/core/event.py index f4dc0ceb..44120908 100644 --- a/src/protean/core/event.py +++ b/src/protean/core/event.py @@ -1,8 +1,7 @@ import logging from protean.utils import DomainObjects, derive_element_class -from protean.utils.container import BaseContainer -from protean.utils.container import OptionsMixin +from protean.utils.container import BaseContainer, OptionsMixin logger = logging.getLogger("protean.event") diff --git a/src/protean/core/repository.py b/src/protean/core/repository.py index 781fc38f..8f98f9f0 100644 --- a/src/protean/core/repository.py +++ b/src/protean/core/repository.py @@ -4,8 +4,7 @@ from protean.exceptions import IncorrectUsageError, ValidationError from protean.globals import current_domain from protean.utils import Database, DomainObjects, derive_element_class -from protean.utils.container import fields -from protean.utils.container import Element, OptionsMixin +from protean.utils.container import Element, OptionsMixin, fields logger = logging.getLogger("protean.repository") diff --git a/src/protean/core/serializer.py b/src/protean/core/serializer.py index a27c1942..661e4659 100644 --- a/src/protean/core/serializer.py +++ b/src/protean/core/serializer.py @@ -20,8 +20,7 @@ ) from protean.exceptions import NotSupportedError from protean.utils import DomainObjects, derive_element_class -from protean.utils.container import _FIELDS, Options -from protean.utils.container import Element +from protean.utils.container import _FIELDS, Element, Options logger = logging.getLogger("protean.application.serializer") diff --git a/src/protean/core/value_object.py b/src/protean/core/value_object.py index 32fbbf8a..13d12529 100644 --- a/src/protean/core/value_object.py +++ b/src/protean/core/value_object.py @@ -1,12 +1,11 @@ """Value Object Functionality and Classes""" import logging -from protean.core.field.association import Reference, Association +from protean.core.field.association import Association, Reference from protean.core.field.embedded import ValueObject from protean.exceptions import IncorrectUsageError from protean.utils import DomainObjects, derive_element_class -from protean.utils.container import BaseContainer, fields -from protean.utils.container import OptionsMixin +from protean.utils.container import BaseContainer, OptionsMixin, fields logger = logging.getLogger("protean.domain.value_object") diff --git a/src/protean/core/view.py b/src/protean/core/view.py index e88c9a85..b2ba88dd 100644 --- a/src/protean/core/view.py +++ b/src/protean/core/view.py @@ -4,17 +4,15 @@ from protean.core.field.association import Association, Reference from protean.core.field.base import Field from protean.core.field.embedded import ValueObject -from protean.exceptions import ( - IncorrectUsageError, - NotSupportedError, +from protean.exceptions import IncorrectUsageError, NotSupportedError +from protean.utils import DomainObjects, derive_element_class, inflection +from protean.utils.container import ( + _ID_FIELD_NAME, + BaseContainer, + OptionsMixin, + fields, + id_field, ) -from protean.utils import ( - DomainObjects, - derive_element_class, - inflection, -) -from protean.utils.container import BaseContainer, fields, _ID_FIELD_NAME, id_field -from protean.utils.container import OptionsMixin logger = logging.getLogger("protean.domain.view") diff --git a/src/protean/domain/__init__.py b/src/protean/domain/__init__.py index 5197fab2..034b04ec 100644 --- a/src/protean/domain/__init__.py +++ b/src/protean/domain/__init__.py @@ -1,10 +1,10 @@ """This module implements the central domain object, along with decorators to register Domain Elements. """ -from collections import defaultdict import logging import sys +from collections import defaultdict from typing import Any, Callable, Dict, List, Optional, Type, Union from werkzeug.datastructures import ImmutableDict diff --git a/src/protean/infra/eventing.py b/src/protean/infra/eventing.py index fa0894d8..2c3b64ca 100644 --- a/src/protean/infra/eventing.py +++ b/src/protean/infra/eventing.py @@ -7,8 +7,7 @@ from protean.core.repository import BaseRepository from protean.globals import current_domain from protean.utils import generate_identity -from protean.utils.container import BaseContainer -from protean.utils.container import OptionsMixin +from protean.utils.container import BaseContainer, OptionsMixin class MessageType(Enum): diff --git a/tests/aggregate/test_aggregate_abstraction.py b/tests/aggregate/test_aggregate_abstraction.py index c2f05b9c..d44dd68f 100644 --- a/tests/aggregate/test_aggregate_abstraction.py +++ b/tests/aggregate/test_aggregate_abstraction.py @@ -1,7 +1,7 @@ import pytest -from protean.utils.container import fields from protean.exceptions import NotSupportedError +from protean.utils.container import fields from .elements import AbstractRole, ConcreteRole diff --git a/tests/aggregate/test_aggregate_initialization.py b/tests/aggregate/test_aggregate_initialization.py index 98571476..b4a1ce00 100644 --- a/tests/aggregate/test_aggregate_initialization.py +++ b/tests/aggregate/test_aggregate_initialization.py @@ -2,8 +2,8 @@ from datetime import datetime import pytest -from protean.core.entity import BaseEntity +from protean.core.entity import BaseEntity from protean.exceptions import ValidationError from protean.utils import fully_qualified_name from protean.utils.container import attributes, fields diff --git a/tests/aggregate/test_aggregate_properties.py b/tests/aggregate/test_aggregate_properties.py index 4a87ba9a..7669373e 100644 --- a/tests/aggregate/test_aggregate_properties.py +++ b/tests/aggregate/test_aggregate_properties.py @@ -5,7 +5,7 @@ from protean.core.field.basic import Auto, String from protean.exceptions import InvalidOperationError, ValidationError -from protean.utils.container import attributes, fields, id_field, _ID_FIELD_NAME +from protean.utils.container import _ID_FIELD_NAME, attributes, fields, id_field from .elements import PersonAutoSSN, PersonExplicitID, Role, RoleClone, SubclassRole diff --git a/tests/entity/test_entity.py b/tests/entity/test_entity.py index e3bff534..3789a891 100644 --- a/tests/entity/test_entity.py +++ b/tests/entity/test_entity.py @@ -4,7 +4,7 @@ from protean.core.entity import BaseEntity from protean.core.field.association import HasOne from protean.core.field.basic import Auto, Integer, String -from protean.utils.container import attributes, fields, Options +from protean.utils.container import Options, attributes, fields class AbstractPerson(BaseEntity): diff --git a/tests/entity/test_entity_meta.py b/tests/entity/test_entity_meta.py index 0ec383db..853df990 100644 --- a/tests/entity/test_entity_meta.py +++ b/tests/entity/test_entity_meta.py @@ -1,5 +1,5 @@ from protean.core.field.basic import Auto, Integer, String -from protean.utils.container import attributes, fields, Options +from protean.utils.container import Options, attributes, fields from .elements import ( AbstractPerson, diff --git a/tests/entity/test_entity_properties.py b/tests/entity/test_entity_properties.py index 395006a5..50f98565 100644 --- a/tests/entity/test_entity_properties.py +++ b/tests/entity/test_entity_properties.py @@ -4,7 +4,7 @@ from protean.core.field.basic import Auto, String from protean.exceptions import InvalidOperationError, ValidationError -from protean.utils.container import attributes, fields, id_field, _ID_FIELD_NAME +from protean.utils.container import _ID_FIELD_NAME, attributes, fields, id_field from .elements import Adult, NotAPerson, Person, PersonAutoSSN, PersonExplicitID diff --git a/tests/entity/test_temp.py b/tests/entity/test_temp.py index b050c9d3..7a72feaf 100644 --- a/tests/entity/test_temp.py +++ b/tests/entity/test_temp.py @@ -1,8 +1,8 @@ import pytest from protean.core.aggregate import BaseAggregate -from protean.exceptions import NotSupportedError from protean.core.field.basic import String +from protean.exceptions import NotSupportedError # Aggregates to test Abstraction # START # diff --git a/tests/field/test_associations.py b/tests/field/test_associations.py index 1224a0a1..7e3a1470 100644 --- a/tests/field/test_associations.py +++ b/tests/field/test_associations.py @@ -1,4 +1,5 @@ from protean.utils.container import attributes, fields + from .elements import Comment, Post diff --git a/tests/infra/test_event_log_structure.py b/tests/infra/test_event_log_structure.py index e74c298e..fa8210e7 100644 --- a/tests/infra/test_event_log_structure.py +++ b/tests/infra/test_event_log_structure.py @@ -1,6 +1,6 @@ from protean.core.field.basic import Auto from protean.infra.eventing import EventLog -from protean.utils.container import fields, attributes +from protean.utils.container import attributes, fields def test_event_log_attributes(): diff --git a/tests/infra/test_job_structure.py b/tests/infra/test_job_structure.py index 3cc7da29..746828ea 100644 --- a/tests/infra/test_job_structure.py +++ b/tests/infra/test_job_structure.py @@ -1,6 +1,6 @@ from protean.core.field.basic import Auto from protean.infra.job import Job -from protean.utils.container import fields, attributes +from protean.utils.container import attributes, fields def test_event_log_attributes(): diff --git a/tests/test_containers.py b/tests/test_containers.py index 6257d0dd..1be22031 100644 --- a/tests/test_containers.py +++ b/tests/test_containers.py @@ -2,8 +2,7 @@ from protean.core.field.basic import Integer, String from protean.exceptions import InvalidDataError -from protean.utils.container import BaseContainer, fields -from protean.utils.container import OptionsMixin +from protean.utils.container import BaseContainer, OptionsMixin, fields class CustomContainerMeta(BaseContainer): diff --git a/tests/views/tests.py b/tests/views/tests.py index 4e03d728..f50045d9 100644 --- a/tests/views/tests.py +++ b/tests/views/tests.py @@ -9,11 +9,11 @@ from protean.exceptions import InvalidOperationError, ValidationError from protean.utils import fully_qualified_name from protean.utils.container import ( + _ID_FIELD_NAME, + Options, attributes, fields, id_field, - _ID_FIELD_NAME, - Options, )