Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.

Commit d5cda07

Browse files
author
James Bell
authored
Merge pull request #91 from chollinger/support/chollinger/fix-ioc
Support/chollinger/fix ioc
2 parents 6219b4d + 86039b8 commit d5cda07

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name='tgt_grease',
7-
version='2.3.8',
7+
version='2.3.9',
88
license="MIT",
99
description='Modern distributed automation engine built with love by Target',
1010
long_description="""

tgt_grease/core/InversionOfControl.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99
class GreaseContainer(object):
1010
"""Inversion of Control Container for objects in GREASE"""
1111

12-
__logger = Logging()
13-
__mongo = None
14-
15-
1612
def __init__(self, *args, **kwargs):
1713
if args or kwargs:
1814
self.getLogger().warning(
1915
"Passing instances of Logger to the IOC is deprecated. Please just use getLogger().", verbose=True
2016
)
17+
self.__logger = None
18+
self.__mongo = None
2119

2220
def getLogger(self):
2321
"""Get the logging instance
@@ -27,7 +25,10 @@ def getLogger(self):
2725
2826
"""
2927

30-
return GreaseContainer.__logger
28+
if not isinstance(self.__logger, Logging):
29+
self.__logger = Logging()
30+
31+
return self.__logger
3132

3233
def getNotification(self):
3334
"""Get the notifications instance
@@ -45,9 +46,11 @@ def getMongo(self):
4546
Mongo: Mongo Instance Connection
4647
4748
"""
48-
if not GreaseContainer.__mongo:
49-
GreaseContainer.__mongo = Mongo(self.getLogger().getConfig())
50-
return GreaseContainer.__mongo
49+
50+
if not isinstance(self.__mongo, Mongo):
51+
self.__mongo = Mongo(self.getLogger().getConfig())
52+
53+
return self.__mongo
5154

5255
def getCollection(self, collectionName):
5356
"""Get a collection object from MongoDB

0 commit comments

Comments
 (0)