Ravi Nori has uploaded a new change for review. Change subject: sdk: Revert Replace decorators before marshal ......................................................................
sdk: Revert Replace decorators before marshal Revert patch Replace decorators before marshal http://gerrit.ovirt.org/#/c/24131 Change-Id: Id18dc425c9bdff54cada4c62a3183fc729ae3b82 Bug-Url: https://bugzilla.redhat.com/1122546 Signed-off-by: Ravi Nori <rn...@redhat.com> --- M src/ovirtsdk/utils/parsehelper.py 1 file changed, 3 insertions(+), 41 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-sdk refs/changes/62/31362/1 diff --git a/src/ovirtsdk/utils/parsehelper.py b/src/ovirtsdk/utils/parsehelper.py index 6f70486..1559937 100644 --- a/src/ovirtsdk/utils/parsehelper.py +++ b/src/ovirtsdk/utils/parsehelper.py @@ -24,50 +24,12 @@ '''Provides parsing capabilities''' @staticmethod - def replaceDecorators(obj): - """ - Returns the object that replaces the given one. If the object is a - resource decorator then it will be replaced by the corresponding - parameters object. Collection decorators will be replaced by None, as - then can't be serialized. - """ - - # Parameter objects don't need to be replaced themselves, but its - # attributes do: - if isinstance(obj, params.GeneratedsSuper): - for attr_name, attr_value in obj.__dict__.iteritems(): - obj.__dict__[attr_name] = ParseHelper.replaceDecorators(attr_value) - return obj - - # Resource decorators are replaced by the reference to the parameters - # object that they store in the "superclass" attribute, collections don't - # have this attribute, so they are replaced by None: - if isinstance(obj, common.Base): - try: - replacement = obj.superclass - except AttributeError: - replacement = None - return replacement - - # Lists have to be iterated and the elements replaced: - if isinstance(obj, list): - replacement = [] - for element in obj: - replacement.append(ParseHelper.replaceDecorators(element)) - return replacement - - # Other types of object don't need any replacement: - return obj - - @staticmethod def toXml(entity): '''Parse entity to corresponding XML representation''' - # The entity given may be a decorator, or it may contain a decorator - # deeply nested. Those decorators can't be serialized to XML, so we - # need to replace all references to decorators with the corresponding - # parameter objects: - entity = ParseHelper.replaceDecorators(entity) + if ReflectionHelper.isModuleMember(sys.modules['ovirtsdk.infrastructure.brokers'], + type(entity)) and hasattr(entity, 'superclass'): + entity = entity.superclass type_name = type(entity).__name__.lower() output = StringIO.StringIO() -- To view, visit http://gerrit.ovirt.org/31362 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id18dc425c9bdff54cada4c62a3183fc729ae3b82 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine-sdk Gerrit-Branch: master Gerrit-Owner: Ravi Nori <rn...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches