Skip to content

Commit

Permalink
Fix event target being overridden
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncoulton committed Feb 27, 2014
1 parent f192a7e commit eee9bf1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,2 +1,2 @@
watson-common == 1.0.2
watson-common == 1.1.0
watson-events == 1.0.2
2 changes: 1 addition & 1 deletion watson/di/__init__.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
__version__ = '2.0.0'
__version__ = '2.0.1'


class ContainerAware(object):
Expand Down
12 changes: 4 additions & 8 deletions watson/di/container.py
Expand Up @@ -87,8 +87,6 @@ class IocContainer(dispatcher.EventDispatcherAware):
"""
config = None
__instantiated__ = None
_pre_process_event = None
_post_process_event = None

def __init__(self, config=None):
"""Initializes the container and set some default configuration options.
Expand Down Expand Up @@ -221,13 +219,11 @@ def _get_type(self, obj):

def _create_instance(self, name, definition):
params = {'definition': definition, 'name': name}
self._pre_process_event.target = self
self._pre_process_event.params = params
result = self.dispatcher.trigger(self._pre_process_event)
event = types.Event(name=PRE_EVENT, target=self, params=params)
result = self.dispatcher.trigger(event)
obj = result.last()
self._post_process_event.target = obj
self._post_process_event.params = params
self.dispatcher.trigger(self._post_process_event)
event = types.Event(name=POST_EVENT, target=obj, params=params)
self.dispatcher.trigger(event)
return obj

def _add_to_instantiated(self, name, item):
Expand Down
4 changes: 1 addition & 3 deletions watson/di/processors.py
@@ -1,10 +1,8 @@
# -*- coding: utf-8 -*-
import abc
from types import FunctionType
from watson.common import imports
from watson.common.contextmanagers import ignored
from watson import di
from watson.di.types import FUNCTION_TYPE, CLASS_TYPE
from watson.di.types import FUNCTION_TYPE


class Base(di.ContainerAware, metaclass=abc.ABCMeta):
Expand Down

0 comments on commit eee9bf1

Please sign in to comment.