Fix dynamic accessor creation on base adapter class
After rebasing on the idiomatic branch it turns out there was an error on the creation of the dynamic accessors. This fixes that issue.
This commit is contained in:
parent
20d3c49893
commit
bce5321154
|
@ -37,9 +37,15 @@ class OpenStackRelationAdapter(object):
|
||||||
for field in self.accessors:
|
for field in self.accessors:
|
||||||
meth_name = field.replace('-', '_')
|
meth_name = field.replace('-', '_')
|
||||||
# Get the relation property dynamically
|
# Get the relation property dynamically
|
||||||
|
# Note the additional lambda name: is to create a closure over
|
||||||
|
# meth_name so that a new 'name' gets created for each loop,
|
||||||
|
# otherwise the same variable meth_name is referenced in each of
|
||||||
|
# the internal lambdas. i.e. this is (lambda x: ...)(value)
|
||||||
setattr(self.__class__,
|
setattr(self.__class__,
|
||||||
meth_name,
|
meth_name,
|
||||||
property(lambda self: getattr(self.relation, meth_name)))
|
(lambda name: property(
|
||||||
|
lambda self: getattr(
|
||||||
|
self.relation, name)()))(meth_name))
|
||||||
|
|
||||||
|
|
||||||
class RabbitMQRelationAdapter(OpenStackRelationAdapter):
|
class RabbitMQRelationAdapter(OpenStackRelationAdapter):
|
||||||
|
|
Loading…
Reference in New Issue