Register proxy directly in add_service

When adding an unknown service to Connection, the existing code was
adding the service's ServiceDescription. Unfortunately, adding a
Descriptor at runtime doesn't actually work and the added instance winds
up being unusable.

As add_service is an active call, we can assume that the person calling
it actually wants to use the service, so we don't need to hid it behind
an on-demand descriptor. Run _make_proxy directly and attach the
resulting proxy to the Connection.

Change-Id: I02aa1ebbd11bea33712a3cb82600abc1aed2a65a
This commit is contained in:
Monty Taylor 2018-11-16 04:18:32 -06:00
parent a7f35beb1d
commit 40322bac04
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594

View File

@ -344,10 +344,11 @@ class Connection(six.with_metaclass(_meta.ConnectionMeta,
# we get an adapter.
if isinstance(service, six.string_types):
service = service_description.ServiceDescription(service)
service_proxy = service._make_proxy(self)
# Register the proxy class with every known alias
for attr_name in service.all_types:
setattr(self, attr_name.replace('-', '_'), service)
setattr(self, attr_name.replace('-', '_'), service_proxy)
def authorize(self):
"""Authorize this Connection