Skip to content
This repository has been archived by the owner on Jul 27, 2019. It is now read-only.

Commit

Permalink
Merge pull request #45 from ApplauseOSS/release-0.14.1
Browse files Browse the repository at this point in the history
Release 0.14.1
  • Loading branch information
jasisz committed Jan 16, 2018
2 parents cce1c16 + 55c0554 commit 8307ac0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 31 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,10 @@
0.14.1
======

- Change the way modules are autodiscovered (use Django utility).
It should work now with new style apps.


0.14.0
======

Expand Down
33 changes: 3 additions & 30 deletions djangoevents/apps.py
@@ -1,12 +1,11 @@
from django.apps import AppConfig as BaseAppConfig
from django.conf import settings
from django.utils.module_loading import import_module
from django.utils.module_loading import autodiscover_modules
from djangoevents import DomainEvent
from .exceptions import EventSchemaError
from .settings import adds_schema_version_to_event_data
from .schema import get_event_version
from .schema import load_all_event_schemas
import os.path
import warnings


Expand All @@ -16,9 +15,8 @@ class AppConfig(BaseAppConfig):
def ready(self):
patch_domain_event()

for app_module_name in get_app_module_names():
import_handlers_module(app_module_name)
import_aggregates_module(app_module_name)
autodiscover_modules('handlers')
autodiscover_modules('aggregates')

# Once all handlers & aggregates are loaded we can import aggregate schema files.
# `load_scheas()` assumes that all aggregates are imported at this point.
Expand All @@ -29,31 +27,6 @@ def get_app_module_names():
return settings.INSTALLED_APPS


def import_handlers_module(app_module_name):
return import_app_module(app_module_name, 'handlers')


def import_aggregates_module(app_module_name):
return import_app_module(app_module_name, 'aggregates')


def import_app_module(app_module_name, module_name):
full_module_name = '%s.%s' % (app_module_name, module_name)
try:
import_module(full_module_name)
except ImportError:
# we need to re-raise exception in case there was import error inside
# `module_name` module
module_file_name = get_module_file_name(app_module_name, module_name)
if os.path.exists(module_file_name):
raise

def get_module_file_name(app_module_name, module_name):
module = import_module(app_module_name)
module_dir = os.path.dirname(module.__file__)
return os.path.join(module_dir, '%s.py' % module_name)


def load_schemas():
"""
Try loading all the event schemas and complain loud if failure occurred.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -13,7 +13,7 @@ def finalize_options(self):

setup(
name='djangoevents',
version='0.14.0',
version='0.14.1',
url='https://github.com/ApplauseOSS/djangoevents',
license='MIT',
description='Building blocks for building Event Sourcing Django applications.',
Expand Down

0 comments on commit 8307ac0

Please sign in to comment.