Skip to content

Commit

Permalink
Merge pull request #1812 from Indicio-tech/feature/allow-external-out…
Browse files Browse the repository at this point in the history
…bound-methods

Fix external Outbound Transport loading code
  • Loading branch information
swcurran authored Jun 21, 2022
2 parents cdea418 + 04573ea commit 5d1988f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions aries_cloudagent/transport/outbound/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ async def setup(self):
for outbound_transport in outbound_transports:
self.register(outbound_transport)

def register(self, module: str) -> str:
def register(self, module_name: str) -> str:
"""
Register a new outbound transport by module path.
Args:
module: Module name to register
module_name: Module name to register
Raises:
OutboundTransportRegistrationError: If the imported class cannot
Expand All @@ -117,13 +117,19 @@ def register(self, module: str) -> str:
"""
try:
if "." in module_name:
package, module = module_name.split(".", 1)
else:
package = MODULE_BASE_PATH
module = module_name

imported_class = ClassLoader.load_subclass_of(
BaseOutboundTransport, module, MODULE_BASE_PATH
BaseOutboundTransport, module, package
)
except (ModuleLoadError, ClassNotFoundError):
except (ModuleLoadError, ClassNotFoundError) as e:
raise OutboundTransportRegistrationError(
f"Outbound transport module {module} could not be resolved."
)
) from e

return self.register_class(imported_class)

Expand Down

0 comments on commit 5d1988f

Please sign in to comment.