Michael Pasternak has posted comments on this change. Change subject: sdk: Add empty export method to decorator base ......................................................................
Patch Set 3: (2 comments) http://gerrit.ovirt.org/#/c/24131/3//COMMIT_MSG Commit Message: Line 16: class VMSnapshotDisk(params.Disk, Base) Line 17: Line 18: This means that resource decorators implement the "export" method, Line 19: responsible for generating the XML representation of the entity, but Line 20: collection decorators don't implement it. > I agree that it doesn't make sense to marshal a collection decorator. But e actually this object decorators never got marshalled, the real object get extracted from decorator *before* marshalling code by params.py: 273.__setattr__ Line 21: Line 22: There are situations where decorators are used as parameters, for Line 23: example, when creating a VM from a snapshot one could use the following Line 24: code: Line 44: they don't have such method. Line 45: Line 46: This usage is not good practice, and not efficient, it is better to Line 47: avoid using decorators as parameters: Line 48: > This doesn't work for collection decorators, because they don't extend the right, but this is only because params.py: 273.__setattr__ not get called when you use setters to assign objects (this is Python thing), otherwise object decorator would never get to the marshalling code, to compare, just do the same, not via setter, but via constructor: snapshot = vm.snapshots.get(id="...") snapshots = ovirtsdk.xml.params.Snapshots(snapshots=[snapshot]) newvm = ovirtsdk.xml.params.VM( name="newvm", snapshots=snapshots, ...) api.vms.add(newvm) and you'll see it works (despite that you using 'snapshot' decorator), to solve this you have to intercep every getter with params.py: 273.__setattr__ logic, so this way object decorator will never get to the marshalling code, Juan, what is drives me for pushing this solution, is a future changes that we can do in the object/collection decorators that will break marshalling again, and force us fixing same issue once more, thus i think decorators should never get to the marshalling infra. Line 49: snapshot = ovirtsdk.params.Snapshot(id="...") Line 50: snapshots = ovirtsdk.params.Snapshots() Line 51: snapshots.add_snapshot(snapshot) Line 52: newvm = ovirtsdk.xml.params.VM( -- To view, visit http://gerrit.ovirt.org/24131 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7843dea85c9f09de5fb3439f57dba71ce6a28898 Gerrit-PatchSet: 3 Gerrit-Project: ovirt-engine-sdk Gerrit-Branch: master Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com> Gerrit-Reviewer: Juan Hernandez <juan.hernan...@redhat.com> Gerrit-Reviewer: Michael Pasternak <mishka8...@yahoo.com> Gerrit-Reviewer: Ravi Nori <rn...@redhat.com> Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches