From 525fe45975837add855c515b4b60bfe8d05f18c3 Mon Sep 17 00:00:00 2001 From: Subhash Bhushan Date: Thu, 25 Jul 2024 11:43:48 -0700 Subject: [PATCH] Nest globals under utils module Expose globals directly under the `protean` namespace. This is part of changes to homogenize and expose (almost) all protean modules under the protean namespace. --- docs_src/guides/change-state/007.py | 2 +- docs_src/guides/composing-a-domain/012.py | 2 +- docs_src/guides/composing-a-domain/018.py | 2 +- src/protean/__init__.py | 4 ++++ src/protean/adapters/broker/__init__.py | 2 +- src/protean/adapters/event_store/memory.py | 2 +- src/protean/adapters/repository/elasticsearch.py | 2 +- src/protean/adapters/repository/memory.py | 2 +- src/protean/adapters/repository/sqlalchemy.py | 2 +- src/protean/core/command.py | 2 +- src/protean/core/event.py | 2 +- src/protean/core/event_sourced_repository.py | 2 +- src/protean/core/queryset.py | 2 +- src/protean/core/repository.py | 2 +- src/protean/core/unit_of_work.py | 2 +- src/protean/domain/__init__.py | 2 +- src/protean/domain/context.py | 2 +- src/protean/fields/association.py | 2 +- src/protean/fields/basic.py | 2 +- src/protean/port/dao.py | 2 +- src/protean/server/engine.py | 2 +- src/protean/utils/__init__.py | 2 +- src/protean/{ => utils}/globals.py | 0 src/protean/utils/mixins.py | 2 +- tests/adapters/broker/celery_broker/elements.py | 2 +- tests/adapters/broker/redis_broker/elements.py | 2 +- tests/adapters/broker/redis_broker/tests.py | 2 +- tests/adapters/email/sendgrid_email/elements.py | 2 +- tests/adapters/model/dict_model/elements.py | 2 +- .../sqlalchemy_model/postgresql/test_array_datatype.py | 2 +- .../sqlalchemy_model/postgresql/test_json_datatype.py | 2 +- tests/adapters/repository/memory/test_any_operator.py | 2 +- tests/adapters/repository/memory/test_in_operator.py | 2 +- .../repository/memory/test_sorting_on_none_values.py | 2 +- .../sqlalchemy_repo/sqlite/test_transactions.py | 2 +- tests/adapters/repository/test_generic.py | 2 +- .../aggregate/events/test_raising_aggregate_events.py | 2 +- tests/context/tests.py | 2 +- tests/domain/tests.py | 2 +- tests/email_provider/elements.py | 2 +- tests/event/elements.py | 2 +- .../test_raising_events_from_within_aggregates.py | 10 ++++++++-- ...ising_multiple_events_for_one_aggregate_in_a_uow.py | 2 +- .../test_loading_aggregates.py | 2 +- .../test_inline_event_processing_on_publish.py | 2 +- tests/message/test_origin_stream_name_in_metadata.py | 2 +- tests/repository/elements.py | 2 +- tests/repository/test_child_persistence.py | 2 +- tests/repository/test_custom_repositories.py | 2 +- tests/unit_of_work/test_inline_event_processing.py | 2 +- .../test_nested_inline_event_processing.py | 2 +- tests/unit_of_work/test_storing_events_on_commit.py | 2 +- tests/workflows/test_event_flows.py | 2 +- 53 files changed, 62 insertions(+), 52 deletions(-) rename src/protean/{ => utils}/globals.py (100%) diff --git a/docs_src/guides/change-state/007.py b/docs_src/guides/change-state/007.py index a0443179..b54f9e26 100644 --- a/docs_src/guides/change-state/007.py +++ b/docs_src/guides/change-state/007.py @@ -3,7 +3,7 @@ from protean import Domain, handle from protean.fields import DateTime, Identifier, String -from protean.globals import current_domain +from protean.utils.globals import current_domain publishing = Domain(__file__, "Publishing", load_toml=False) diff --git a/docs_src/guides/composing-a-domain/012.py b/docs_src/guides/composing-a-domain/012.py index ec0e8d70..a5dcfc9b 100644 --- a/docs_src/guides/composing-a-domain/012.py +++ b/docs_src/guides/composing-a-domain/012.py @@ -2,7 +2,7 @@ from protean import Domain from protean.fields import Integer, String -from protean.globals import current_domain +from protean.utils.globals import current_domain domain = Domain(__file__, load_toml=False) diff --git a/docs_src/guides/composing-a-domain/018.py b/docs_src/guides/composing-a-domain/018.py index 3de277b2..726e7e44 100644 --- a/docs_src/guides/composing-a-domain/018.py +++ b/docs_src/guides/composing-a-domain/018.py @@ -1,6 +1,6 @@ from protean import Domain from protean.fields import Integer, String -from protean.globals import current_domain +from protean.utils.globals import current_domain domain = Domain(__file__, load_toml=False) diff --git a/src/protean/__init__.py b/src/protean/__init__.py index 185a038d..13bd3278 100644 --- a/src/protean/__init__.py +++ b/src/protean/__init__.py @@ -20,6 +20,7 @@ from .domain import Domain from .server import Engine from .utils import get_version +from .utils.globals import current_domain, current_uow, g from .utils.mixins import handle __all__ = [ @@ -48,4 +49,7 @@ "handle", "invariant", "atomic_change", + "current_domain", + "current_uow", + "g", ] diff --git a/src/protean/adapters/broker/__init__.py b/src/protean/adapters/broker/__init__.py index 1e6ac9a9..02c721ad 100644 --- a/src/protean/adapters/broker/__init__.py +++ b/src/protean/adapters/broker/__init__.py @@ -4,7 +4,7 @@ from protean.core.event import BaseEvent from protean.exceptions import ConfigurationError -from protean.globals import current_uow +from protean.utils.globals import current_uow from protean.utils.mixins import Message logger = logging.getLogger(__name__) diff --git a/src/protean/adapters/event_store/memory.py b/src/protean/adapters/event_store/memory.py index 5d033eed..25d53f61 100644 --- a/src/protean/adapters/event_store/memory.py +++ b/src/protean/adapters/event_store/memory.py @@ -3,8 +3,8 @@ from protean.core.aggregate import BaseAggregate from protean.core.repository import BaseRepository -from protean.globals import current_domain from protean.port.event_store import BaseEventStore +from protean.utils.globals import current_domain from protean.utils.mixins import MessageRecord diff --git a/src/protean/adapters/repository/elasticsearch.py b/src/protean/adapters/repository/elasticsearch.py index cbe117a6..90de8d40 100644 --- a/src/protean/adapters/repository/elasticsearch.py +++ b/src/protean/adapters/repository/elasticsearch.py @@ -14,11 +14,11 @@ from protean.core.queryset import ResultSet from protean.exceptions import ObjectNotFoundError from protean.fields import Reference -from protean.globals import current_domain from protean.port.dao import BaseDAO, BaseLookup from protean.port.provider import BaseProvider from protean.reflection import attributes, id_field from protean.utils import IdentityStrategy, IdentityType +from protean.utils.globals import current_domain from protean.utils.query import Q logger = logging.getLogger(__name__) diff --git a/src/protean/adapters/repository/memory.py b/src/protean/adapters/repository/memory.py index 0c004c62..e754e5e1 100644 --- a/src/protean/adapters/repository/memory.py +++ b/src/protean/adapters/repository/memory.py @@ -15,10 +15,10 @@ from protean.core.queryset import ResultSet from protean.exceptions import ObjectNotFoundError, ValidationError from protean.fields.basic import Auto -from protean.globals import current_uow from protean.port.dao import BaseDAO, BaseLookup from protean.port.provider import BaseProvider from protean.reflection import attributes, fields, id_field +from protean.utils.globals import current_uow from protean.utils.query import Q diff --git a/src/protean/adapters/repository/sqlalchemy.py b/src/protean/adapters/repository/sqlalchemy.py index bfa8391f..2815e0b6 100644 --- a/src/protean/adapters/repository/sqlalchemy.py +++ b/src/protean/adapters/repository/sqlalchemy.py @@ -39,11 +39,11 @@ ) from protean.fields.association import Reference, _ReferenceField from protean.fields.embedded import _ShadowField -from protean.globals import current_domain, current_uow from protean.port.dao import BaseDAO, BaseLookup from protean.port.provider import BaseProvider from protean.reflection import attributes, id_field from protean.utils import IdentityType +from protean.utils.globals import current_domain, current_uow from protean.utils.query import Q logging.getLogger("sqlalchemy").setLevel(logging.ERROR) diff --git a/src/protean/core/command.py b/src/protean/core/command.py index 3cd9c546..a4919b95 100644 --- a/src/protean/core/command.py +++ b/src/protean/core/command.py @@ -4,9 +4,9 @@ NotSupportedError, ValidationError, ) -from protean.globals import g from protean.utils import DomainObjects, derive_element_class, fqn from protean.utils.eventing import BaseMessageType, Metadata +from protean.utils.globals import g class BaseCommand(BaseMessageType): diff --git a/src/protean/core/event.py b/src/protean/core/event.py index b73f4b7c..7396b05f 100644 --- a/src/protean/core/event.py +++ b/src/protean/core/event.py @@ -4,9 +4,9 @@ IncorrectUsageError, NotSupportedError, ) -from protean.globals import g from protean.utils import DomainObjects, derive_element_class, fqn from protean.utils.eventing import BaseMessageType, Metadata +from protean.utils.globals import g logger = logging.getLogger(__name__) diff --git a/src/protean/core/event_sourced_repository.py b/src/protean/core/event_sourced_repository.py index f605504d..6031fe84 100644 --- a/src/protean/core/event_sourced_repository.py +++ b/src/protean/core/event_sourced_repository.py @@ -8,8 +8,8 @@ ObjectNotFoundError, ) from protean.fields import Identifier -from protean.globals import current_uow from protean.utils import DomainObjects, derive_element_class +from protean.utils.globals import current_uow logger = logging.getLogger(__name__) diff --git a/src/protean/core/queryset.py b/src/protean/core/queryset.py index 047b1f52..6324d0ad 100644 --- a/src/protean/core/queryset.py +++ b/src/protean/core/queryset.py @@ -6,8 +6,8 @@ import logging from typing import TYPE_CHECKING, Any, Union -from protean.globals import current_uow from protean.utils import DomainObjects +from protean.utils.globals import current_uow from protean.utils.query import Q if TYPE_CHECKING: diff --git a/src/protean/core/repository.py b/src/protean/core/repository.py index c0a08bfa..d16c6d11 100644 --- a/src/protean/core/repository.py +++ b/src/protean/core/repository.py @@ -10,7 +10,6 @@ from protean.core.view import BaseView from protean.exceptions import IncorrectUsageError, NotSupportedError from protean.fields import HasMany, HasOne -from protean.globals import current_domain, current_uow from protean.port.dao import BaseDAO from protean.port.provider import BaseProvider from protean.reflection import association_fields, has_association_fields @@ -20,6 +19,7 @@ derive_element_class, fully_qualified_name, ) +from protean.utils.globals import current_domain, current_uow if TYPE_CHECKING: from protean.domain import Domain diff --git a/src/protean/core/unit_of_work.py b/src/protean/core/unit_of_work.py index 8d6410fa..0244a528 100644 --- a/src/protean/core/unit_of_work.py +++ b/src/protean/core/unit_of_work.py @@ -6,9 +6,9 @@ InvalidOperationError, ValidationError, ) -from protean.globals import _uow_context_stack, current_domain from protean.reflection import id_field from protean.utils import EventProcessing +from protean.utils.globals import _uow_context_stack, current_domain logger = logging.getLogger(__name__) diff --git a/src/protean/domain/__init__.py b/src/protean/domain/__init__.py index 9d4d57c8..00c2a152 100644 --- a/src/protean/domain/__init__.py +++ b/src/protean/domain/__init__.py @@ -31,7 +31,6 @@ ) from protean.fields import HasMany, HasOne, Reference, ValueObject from protean.fields import List as ProteanList -from protean.globals import g from protean.reflection import declared_fields, has_fields, id_field from protean.utils import ( CommandProcessing, @@ -39,6 +38,7 @@ EventProcessing, fqn, ) +from protean.utils.globals import g from .config import Config2, ConfigAttribute from .context import DomainContext, _DomainContextGlobals diff --git a/src/protean/domain/context.py b/src/protean/domain/context.py index 389f15f9..1624a625 100644 --- a/src/protean/domain/context.py +++ b/src/protean/domain/context.py @@ -3,7 +3,7 @@ import logging import sys -from protean.globals import _domain_context_stack +from protean.utils.globals import _domain_context_stack # a singleton sentinel value for parameter defaults _sentinel = object() diff --git a/src/protean/fields/association.py b/src/protean/fields/association.py index 83c3a78c..fc1faeb6 100644 --- a/src/protean/fields/association.py +++ b/src/protean/fields/association.py @@ -2,8 +2,8 @@ from protean import exceptions, utils from protean.exceptions import ValidationError -from protean.globals import current_domain from protean.reflection import association_fields, has_association_fields, id_field +from protean.utils.globals import current_domain from .base import Field, FieldBase from .mixins import FieldCacheMixin, FieldDescriptorMixin diff --git a/src/protean/fields/basic.py b/src/protean/fields/basic.py index 1eae0104..e6ea3a95 100644 --- a/src/protean/fields/basic.py +++ b/src/protean/fields/basic.py @@ -9,8 +9,8 @@ from protean.exceptions import InvalidOperationError, ValidationError from protean.fields import Field, validators from protean.fields.embedded import ValueObject -from protean.globals import current_domain from protean.utils import IdentityType +from protean.utils.globals import current_domain class String(Field): diff --git a/src/protean/port/dao.py b/src/protean/port/dao.py index fd0847e9..64aeb9a9 100644 --- a/src/protean/port/dao.py +++ b/src/protean/port/dao.py @@ -14,10 +14,10 @@ ValidationError, ) from protean.fields import Auto, Field -from protean.globals import current_uow from protean.port.provider import BaseProvider from protean.reflection import declared_fields, id_field, unique_fields from protean.utils import DomainObjects +from protean.utils.globals import current_uow from protean.utils.query import Q if TYPE_CHECKING: diff --git a/src/protean/server/engine.py b/src/protean/server/engine.py index fc2837a2..90244003 100644 --- a/src/protean/server/engine.py +++ b/src/protean/server/engine.py @@ -8,7 +8,7 @@ from protean.core.command_handler import BaseCommandHandler from protean.core.event_handler import BaseEventHandler -from protean.globals import g +from protean.utils.globals import g from protean.utils.mixins import Message from .subscription import Subscription diff --git a/src/protean/utils/__init__.py b/src/protean/utils/__init__.py index 7fed2290..257d0b89 100644 --- a/src/protean/utils/__init__.py +++ b/src/protean/utils/__init__.py @@ -12,7 +12,7 @@ from uuid import uuid4 from protean.exceptions import ConfigurationError -from protean.globals import current_domain +from protean.utils.globals import current_domain logger = logging.getLogger(__name__) diff --git a/src/protean/globals.py b/src/protean/utils/globals.py similarity index 100% rename from src/protean/globals.py rename to src/protean/utils/globals.py diff --git a/src/protean/utils/mixins.py b/src/protean/utils/mixins.py index de69645d..29facffa 100644 --- a/src/protean/utils/mixins.py +++ b/src/protean/utils/mixins.py @@ -12,8 +12,8 @@ from protean.core.event import BaseEvent from protean.core.unit_of_work import UnitOfWork from protean.exceptions import ConfigurationError, InvalidDataError -from protean.globals import current_domain from protean.utils.eventing import Metadata +from protean.utils.globals import current_domain logger = logging.getLogger(__name__) diff --git a/tests/adapters/broker/celery_broker/elements.py b/tests/adapters/broker/celery_broker/elements.py index b939dbdf..b92e0b76 100644 --- a/tests/adapters/broker/celery_broker/elements.py +++ b/tests/adapters/broker/celery_broker/elements.py @@ -1,6 +1,6 @@ from protean import BaseAggregate, BaseEvent, BaseSubscriber from protean.fields import Auto, Integer, String -from protean.globals import current_domain +from protean.utils.globals import current_domain class Person(BaseAggregate): diff --git a/tests/adapters/broker/redis_broker/elements.py b/tests/adapters/broker/redis_broker/elements.py index b939dbdf..b92e0b76 100644 --- a/tests/adapters/broker/redis_broker/elements.py +++ b/tests/adapters/broker/redis_broker/elements.py @@ -1,6 +1,6 @@ from protean import BaseAggregate, BaseEvent, BaseSubscriber from protean.fields import Auto, Integer, String -from protean.globals import current_domain +from protean.utils.globals import current_domain class Person(BaseAggregate): diff --git a/tests/adapters/broker/redis_broker/tests.py b/tests/adapters/broker/redis_broker/tests.py index 9c73d5a5..703725dc 100644 --- a/tests/adapters/broker/redis_broker/tests.py +++ b/tests/adapters/broker/redis_broker/tests.py @@ -4,7 +4,7 @@ import redis from protean.adapters.broker.redis import RedisBroker -from protean.globals import current_domain +from protean.utils.globals import current_domain from .elements import Person, PersonAdded diff --git a/tests/adapters/email/sendgrid_email/elements.py b/tests/adapters/email/sendgrid_email/elements.py index 365def73..273c047e 100644 --- a/tests/adapters/email/sendgrid_email/elements.py +++ b/tests/adapters/email/sendgrid_email/elements.py @@ -1,7 +1,7 @@ from protean import BaseAggregate, BaseEmail, BaseEvent, BaseSubscriber from protean.exceptions import InsufficientDataError, InvalidDataError from protean.fields import Integer, String -from protean.globals import current_domain +from protean.utils.globals import current_domain class Person(BaseAggregate): diff --git a/tests/adapters/model/dict_model/elements.py b/tests/adapters/model/dict_model/elements.py index dc52a5dd..7ae7441e 100644 --- a/tests/adapters/model/dict_model/elements.py +++ b/tests/adapters/model/dict_model/elements.py @@ -4,7 +4,7 @@ from protean import BaseAggregate, BaseModel, BaseRepository, BaseValueObject, invariant from protean.exceptions import ValidationError from protean.fields import Integer, String, Text, ValueObject -from protean.globals import current_domain +from protean.utils.globals import current_domain class Person(BaseAggregate): diff --git a/tests/adapters/model/sqlalchemy_model/postgresql/test_array_datatype.py b/tests/adapters/model/sqlalchemy_model/postgresql/test_array_datatype.py index 74697c2c..c9f7cd8c 100644 --- a/tests/adapters/model/sqlalchemy_model/postgresql/test_array_datatype.py +++ b/tests/adapters/model/sqlalchemy_model/postgresql/test_array_datatype.py @@ -16,7 +16,7 @@ List, String, ) -from protean.globals import current_domain +from protean.utils.globals import current_domain class ArrayUser(BaseAggregate): diff --git a/tests/adapters/model/sqlalchemy_model/postgresql/test_json_datatype.py b/tests/adapters/model/sqlalchemy_model/postgresql/test_json_datatype.py index 405ebac9..b4a2efbb 100644 --- a/tests/adapters/model/sqlalchemy_model/postgresql/test_json_datatype.py +++ b/tests/adapters/model/sqlalchemy_model/postgresql/test_json_datatype.py @@ -3,8 +3,8 @@ from protean import BaseAggregate from protean.fields import DateTime, Dict, String -from protean.globals import current_domain from protean.utils import utcnow_func +from protean.utils.globals import current_domain class Event(BaseAggregate): diff --git a/tests/adapters/repository/memory/test_any_operator.py b/tests/adapters/repository/memory/test_any_operator.py index b1b52a41..f40b3821 100644 --- a/tests/adapters/repository/memory/test_any_operator.py +++ b/tests/adapters/repository/memory/test_any_operator.py @@ -1,6 +1,6 @@ from protean import BaseAggregate from protean.fields import List -from protean.globals import current_domain +from protean.utils.globals import current_domain class User(BaseAggregate): diff --git a/tests/adapters/repository/memory/test_in_operator.py b/tests/adapters/repository/memory/test_in_operator.py index 30c31e53..fdc09163 100644 --- a/tests/adapters/repository/memory/test_in_operator.py +++ b/tests/adapters/repository/memory/test_in_operator.py @@ -1,6 +1,6 @@ from protean import BaseAggregate from protean.fields.basic import String -from protean.globals import current_domain +from protean.utils.globals import current_domain class User(BaseAggregate): diff --git a/tests/adapters/repository/memory/test_sorting_on_none_values.py b/tests/adapters/repository/memory/test_sorting_on_none_values.py index 49cf5ae3..6d4877d9 100644 --- a/tests/adapters/repository/memory/test_sorting_on_none_values.py +++ b/tests/adapters/repository/memory/test_sorting_on_none_values.py @@ -2,7 +2,7 @@ from protean import BaseAggregate from protean.fields import Date, Integer, String -from protean.globals import current_domain +from protean.utils.globals import current_domain class User(BaseAggregate): diff --git a/tests/adapters/repository/sqlalchemy_repo/sqlite/test_transactions.py b/tests/adapters/repository/sqlalchemy_repo/sqlite/test_transactions.py index a0850c95..39f59dfb 100644 --- a/tests/adapters/repository/sqlalchemy_repo/sqlite/test_transactions.py +++ b/tests/adapters/repository/sqlalchemy_repo/sqlite/test_transactions.py @@ -4,7 +4,7 @@ import pytest from protean import UnitOfWork -from protean.globals import current_uow +from protean.utils.globals import current_uow from .elements import Person, PersonRepository diff --git a/tests/adapters/repository/test_generic.py b/tests/adapters/repository/test_generic.py index 2c93bec3..37134abf 100644 --- a/tests/adapters/repository/test_generic.py +++ b/tests/adapters/repository/test_generic.py @@ -13,7 +13,7 @@ ) from protean.exceptions import ExpectedVersionError, ValidationError from protean.fields import Integer, String, ValueObject -from protean.globals import current_domain +from protean.utils.globals import current_domain class Person(BaseAggregate): diff --git a/tests/aggregate/events/test_raising_aggregate_events.py b/tests/aggregate/events/test_raising_aggregate_events.py index 3bc7cd7e..317c7fb7 100644 --- a/tests/aggregate/events/test_raising_aggregate_events.py +++ b/tests/aggregate/events/test_raising_aggregate_events.py @@ -5,7 +5,7 @@ from protean import BaseAggregate, BaseEntity, BaseEvent from protean.core.unit_of_work import UnitOfWork from protean.fields import HasOne, Identifier, String -from protean.globals import current_domain +from protean.utils.globals import current_domain class UserStatus(Enum): diff --git a/tests/context/tests.py b/tests/context/tests.py index a4a046b4..3fe8dc26 100644 --- a/tests/context/tests.py +++ b/tests/context/tests.py @@ -1,6 +1,6 @@ import pytest -from protean.globals import current_domain, g +from protean.utils.globals import current_domain, g class TestDomainContext: diff --git a/tests/domain/tests.py b/tests/domain/tests.py index 149ae164..bd630678 100644 --- a/tests/domain/tests.py +++ b/tests/domain/tests.py @@ -295,7 +295,7 @@ class Comment(BaseEntity): ) # Remove domain context manually, as we lost it when the exception was raised - from protean.globals import _domain_context_stack + from protean.utils.globals import _domain_context_stack _domain_context_stack.pop() diff --git a/tests/email_provider/elements.py b/tests/email_provider/elements.py index 8cb09a19..8a8cfcc6 100644 --- a/tests/email_provider/elements.py +++ b/tests/email_provider/elements.py @@ -1,7 +1,7 @@ from protean import BaseAggregate, BaseEmail, BaseEvent, BaseSubscriber from protean.exceptions import InsufficientDataError, InvalidDataError from protean.fields import Identifier, Integer, String -from protean.globals import current_domain +from protean.utils.globals import current_domain class Person(BaseAggregate): diff --git a/tests/event/elements.py b/tests/event/elements.py index 66d5af31..ef7bdd81 100644 --- a/tests/event/elements.py +++ b/tests/event/elements.py @@ -6,7 +6,7 @@ UnitOfWork, ) from protean.fields import Identifier, Integer, String -from protean.globals import current_domain +from protean.utils.globals import current_domain class PersonCommand(BaseCommand): diff --git a/tests/event_sourced_aggregates/test_raising_events_from_within_aggregates.py b/tests/event_sourced_aggregates/test_raising_events_from_within_aggregates.py index 76a39588..45f25556 100644 --- a/tests/event_sourced_aggregates/test_raising_events_from_within_aggregates.py +++ b/tests/event_sourced_aggregates/test_raising_events_from_within_aggregates.py @@ -4,10 +4,16 @@ import pytest -from protean import BaseAggregate, BaseCommandHandler, BaseEvent, apply, handle +from protean import ( + BaseAggregate, + BaseCommandHandler, + BaseEvent, + apply, + current_domain, + handle, +) from protean.core.command import BaseCommand from protean.fields import Identifier, String -from protean.globals import current_domain class Register(BaseCommand): diff --git a/tests/event_sourced_aggregates/test_raising_multiple_events_for_one_aggregate_in_a_uow.py b/tests/event_sourced_aggregates/test_raising_multiple_events_for_one_aggregate_in_a_uow.py index 62dee530..2bd0282f 100644 --- a/tests/event_sourced_aggregates/test_raising_multiple_events_for_one_aggregate_in_a_uow.py +++ b/tests/event_sourced_aggregates/test_raising_multiple_events_for_one_aggregate_in_a_uow.py @@ -13,7 +13,7 @@ handle, ) from protean.fields import Identifier, String -from protean.globals import current_domain +from protean.utils.globals import current_domain class Register(BaseCommand): diff --git a/tests/event_sourced_repository/test_loading_aggregates.py b/tests/event_sourced_repository/test_loading_aggregates.py index 69037e17..b383dedc 100644 --- a/tests/event_sourced_repository/test_loading_aggregates.py +++ b/tests/event_sourced_repository/test_loading_aggregates.py @@ -15,7 +15,7 @@ from protean.exceptions import ObjectNotFoundError from protean.fields import Identifier, String from protean.fields.basic import Boolean -from protean.globals import current_domain +from protean.utils.globals import current_domain class Register(BaseCommand): diff --git a/tests/event_store/test_inline_event_processing_on_publish.py b/tests/event_store/test_inline_event_processing_on_publish.py index 6fd22e7f..3a8a161b 100644 --- a/tests/event_store/test_inline_event_processing_on_publish.py +++ b/tests/event_store/test_inline_event_processing_on_publish.py @@ -11,7 +11,7 @@ from protean import BaseAggregate, BaseEvent, BaseEventHandler, handle from protean.fields import Identifier, String -from protean.globals import current_domain +from protean.utils.globals import current_domain counter = 0 diff --git a/tests/message/test_origin_stream_name_in_metadata.py b/tests/message/test_origin_stream_name_in_metadata.py index 314598d7..1f435091 100644 --- a/tests/message/test_origin_stream_name_in_metadata.py +++ b/tests/message/test_origin_stream_name_in_metadata.py @@ -6,7 +6,7 @@ from protean.core.event import Metadata from protean.fields import String from protean.fields.basic import Identifier -from protean.globals import g +from protean.utils.globals import g from protean.utils.mixins import Message diff --git a/tests/repository/elements.py b/tests/repository/elements.py index f3f6534f..70d6a55b 100644 --- a/tests/repository/elements.py +++ b/tests/repository/elements.py @@ -4,7 +4,7 @@ from protean import BaseAggregate, BaseRepository, BaseValueObject, invariant from protean.exceptions import ValidationError from protean.fields import Integer, String, ValueObject -from protean.globals import current_domain +from protean.utils.globals import current_domain class Person(BaseAggregate): diff --git a/tests/repository/test_child_persistence.py b/tests/repository/test_child_persistence.py index c10a0fc8..3bfe701c 100644 --- a/tests/repository/test_child_persistence.py +++ b/tests/repository/test_child_persistence.py @@ -1,6 +1,6 @@ import pytest -from protean.globals import current_domain +from protean.utils.globals import current_domain from .child_entities import Comment, Post, PostMeta diff --git a/tests/repository/test_custom_repositories.py b/tests/repository/test_custom_repositories.py index a1184eed..386cc613 100644 --- a/tests/repository/test_custom_repositories.py +++ b/tests/repository/test_custom_repositories.py @@ -4,8 +4,8 @@ from protean import BaseAggregate, BaseRepository from protean.fields import Integer, String -from protean.globals import current_domain from protean.utils import fully_qualified_name +from protean.utils.globals import current_domain class PersonGeneric(BaseAggregate): diff --git a/tests/unit_of_work/test_inline_event_processing.py b/tests/unit_of_work/test_inline_event_processing.py index 43db627c..fdf261fd 100644 --- a/tests/unit_of_work/test_inline_event_processing.py +++ b/tests/unit_of_work/test_inline_event_processing.py @@ -14,7 +14,7 @@ handle, ) from protean.fields import Boolean, Identifier, String -from protean.globals import current_domain +from protean.utils.globals import current_domain counter = 0 diff --git a/tests/unit_of_work/test_nested_inline_event_processing.py b/tests/unit_of_work/test_nested_inline_event_processing.py index 7ffbb1f2..cb0ddfa8 100644 --- a/tests/unit_of_work/test_nested_inline_event_processing.py +++ b/tests/unit_of_work/test_nested_inline_event_processing.py @@ -15,8 +15,8 @@ ) from protean.fields import DateTime, Identifier, String, Text from protean.fields.basic import Boolean -from protean.globals import current_domain from protean.utils import utcnow_func +from protean.utils.globals import current_domain published_count = 0 diff --git a/tests/unit_of_work/test_storing_events_on_commit.py b/tests/unit_of_work/test_storing_events_on_commit.py index 003e1dc6..dfd5041c 100644 --- a/tests/unit_of_work/test_storing_events_on_commit.py +++ b/tests/unit_of_work/test_storing_events_on_commit.py @@ -8,7 +8,7 @@ from protean.core.command import BaseCommand from protean.fields import String from protean.fields.basic import Identifier -from protean.globals import current_domain +from protean.utils.globals import current_domain class Register(BaseCommand): diff --git a/tests/workflows/test_event_flows.py b/tests/workflows/test_event_flows.py index 1a13b56e..b0fdb968 100644 --- a/tests/workflows/test_event_flows.py +++ b/tests/workflows/test_event_flows.py @@ -34,9 +34,9 @@ String, ValueObject, ) -from protean.globals import current_domain from protean.server import Engine from protean.utils import CommandProcessing, EventProcessing +from protean.utils.globals import current_domain class Order(BaseAggregate):