4545
4646from sonar .portfolio_reference import PortfolioReference
4747
48- _OBJECTS = {}
4948_CLASS_LOCK = Lock ()
5049
5150_CREATE_API = "views/create"
@@ -90,6 +89,8 @@ class Portfolio(aggregations.Aggregation):
9089 SEARCH_KEY_FIELD = "key"
9190 SEARCH_RETURN_FIELD = "components"
9291
92+ _OBJECTS = {}
93+
9394 def __init__ (self , endpoint : pf .Platform , name : str , key : str = None ) -> None :
9495 """Constructor, don't use - use class methods instead"""
9596 if not key :
@@ -107,7 +108,7 @@ def __init__(self, endpoint: pf.Platform, name: str, key: str = None) -> None:
107108 self .is_sub_portfolio = None
108109 self .parent = None #: Ref to parent portfolio object, if any
109110 self ._root_portfolio = None #: Ref to root portfolio, if any
110- _OBJECTS [self .uuid ()] = self
111+ Portfolio . _OBJECTS [self .uuid ()] = self
111112 log .debug ("Created portfolio object name '%s'" , name )
112113
113114 @classmethod
@@ -116,8 +117,8 @@ def get_object(cls, endpoint: pf.Platform, key: str) -> Portfolio:
116117 check_supported (endpoint )
117118 log .debug ("Getting portfolio object key '%s'" , key )
118119 uid = sq .uuid (key , endpoint .url )
119- if uid in _OBJECTS :
120- return _OBJECTS [uid ]
120+ if uid in Portfolio . _OBJECTS :
121+ return Portfolio . _OBJECTS [uid ]
121122 data = search_by_key (endpoint , key )
122123 if data is None :
123124 raise exceptions .ObjectNotFound (key , f"Portfolio key '{ key } ' not found" )
@@ -311,7 +312,7 @@ def get_components(self) -> types.ApiPayload:
311312
312313 def delete (self ) -> bool :
313314 """Deletes a portfolio, returns whether the operation succeeded"""
314- return sq .delete_object (self , "views/delete" , {"key" : self .key }, _OBJECTS )
315+ return sq .delete_object (self , "views/delete" , {"key" : self .key }, Portfolio . _OBJECTS )
315316
316317 def _audit_empty (self , audit_settings : types .ConfigSettings ) -> list [problem .Problem ]:
317318 """Audits if a portfolio is empty (no projects)"""
@@ -623,6 +624,7 @@ def get_list(endpoint: pf.Platform, key_list: types.KeyList = None, use_cache: b
623624 if key_list is None or len (key_list ) == 0 or not use_cache :
624625 log .info ("Listing portfolios" )
625626 object_list = search (endpoint = endpoint )
627+ log .info ("List = %s" , ", " .join (list (object_list .keys ())))
626628 return object_list
627629 object_list = {}
628630 for key in util .csv_to_list (key_list ):
0 commit comments