Juan Hernandez has posted comments on this change. Change subject: sdk: Save attributes to decorated object ......................................................................
Patch Set 3: (3 comments) http://gerrit.ovirt.org/#/c/30653/3/src/ovirtsdk/infrastructure/common.py File src/ovirtsdk/infrastructure/common.py: Line 34: attribute named "superclass". This name is required for backwards Line 35: compatibility with the CLI.""" Line 36: Line 37: def __init__(self, context): Line 38: self.__dict__[CONTEXT_ATTR] = context > juan, It was already accessible: @property def context(self): return self.__context Line 39: Line 40: def __getattr__(self, name): Line 41: decorated = self.__dict__.get(DECORATED_ATTR) Line 42: if name == DECORATED_ATTR: Line 43: return decorated Line 44: if name == CONTEXT_ATTR: Line 45: return self.__dict__.get(CONTEXT_ATTR) Line 46: if decorated is not None: Line 47: return getattr(decorated, name) > i guess this if clouse should come after the one bellow [1], otherwise What this is doing is making sure that all attributes except "decorated" and "context" are stored in the decorated object, not in the broker object. So the check for both names ("decorated" and "context") most be done before any other name. Line 48: if name in self.__dict__: Line 49: return self.__dict__[name] Line 50: raise AttributeError("'%s' broker object has no attribute '%s'" % (type(self).__name__, name)) Line 51: Line 58: decorated = self.__dict__.get(DECORATED_ATTR) Line 59: if decorated is not None: Line 60: setattr(decorated, name, value) Line 61: else: Line 62: self.__dict__[name] = value > Hi Juan, 1. Typos in attribute names are silently ignored by Python anyhow: from ovirtsdk.xml import params vm = params.VM() vm.this_is_a_typo = "but it will succeed" So no difference in those regards. 2. Ok, will do. Line 63: Line 64: def __eq__(self, other): Line 65: return Comparator.compare(self, other) Line 66: -- To view, visit http://gerrit.ovirt.org/30653 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4a4c5e08f844b250b585508c962fc0c38f9aad98 Gerrit-PatchSet: 3 Gerrit-Project: ovirt-engine-sdk Gerrit-Branch: master Gerrit-Owner: Juan Hernandez <[email protected]> Gerrit-Reviewer: Juan Hernandez <[email protected]> Gerrit-Reviewer: Michael Pasternak <[email protected]> Gerrit-Reviewer: Ravi Nori <[email protected]> Gerrit-Reviewer: [email protected] Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
