[BUG-15347] ObjectWrapper modification

#1

Dears,
I am currently using the 8.0.5 release.
After the upgrade from the 8.0.4, I noticed a change in the manipulation of an ObjectWrapper instance.
For example:
the code below explains what I found: the param parameter is an ObjectWrapper

# Configure additional properties
param.Username 	= userName
param.Timestamp = fer.util.date.dateToSqlString(fer.util.date.getTimestampUtc())

I try to set the Username and Timestamp properties, but they did not change.
The above code run inside a library in Project Library.

Any idea of this strange behavior?
Thank you.

0 Likes

#2

I did another test and the result is still unexpected.
I created a simple function, that assigns a property value to an object:

> def fnc(obj, key, value):
> 	system.perspective.print('key %s' % key)
> 	system.perspective.print('value %s' % value)
> 	system.perspective.print('id %s' % id(obj))
> 	
> 	#setattr(obj, key, value)
> 	execStr = 'obj.%s = "%s"' % (key, value)
> 	exec(execStr)
> 	
> 	system.perspective.print('obj %s' % obj)
> 	system.perspective.print('id %s' % id(obj))
> 	
> 	return obj

The function is called in a button ActionPerformed action, by:

	self.view.custom.tree = fer.provaLib.fnc(obj=self.view.custom.tree
										, key=self.getSibling("TextField").props.text
										, value=self.getSibling("TextField_0").props.text)

The result is again an object with the same structure, without the expected new property-value pair.

How can I solve this issue?
Please consider I developed many libraries with that logic and they have worked, before the 8.0.5 upgrade.

Let me know, thank you.
Andrea

0 Likes

#3

@PGriffith

Probably related to the same changes causing this: [BUG] tolist() broken in 8.0.5

0 Likes

#4

Do you need further information to fix it?
Let me know.

0 Likes

#5

On the ActionPerformed of the same button, the direct assignment of a new property, as
self.view.custom.tree.test = 'test', works fine.

0 Likes

#6

There’s something a bit weird here, definitely. We’ve got our defect analysts working on isolating the issue - it’s fairly easy to reproduce.

0 Likes

#7

With the way that the function is called, it should work if you change:

self.view.custom.tree = fer.provaLib.fnc(obj=self.view.custom.tree
										, key=self.getSibling("TextField").props.text
										, value=self.getSibling("TextField_0").props.text)

to just:

fer.provaLib.fnc(obj=self.view.custom.tree
					, key=self.getSibling("TextField").props.text
					, value=self.getSibling("TextField_0").props.text)

Since the fnc() function is directly editing the object passed in. While this shouldn’t be an issue and is a bug that will be fixed, the workaround is to just not re-assign the object to be equal to itself.

0 Likes

#8

Thank you all.
Let me know (as soon as possible :grinning:) when the bug will be fixed.
Unfortunately this gateway is in production and I need to understand which workaround to take.

Bye,
Andrea

0 Likes

#9

Just to inform you that, in the example above, also the method obj.update({key: value}) and the syntax obj[key] = value do not modify the object obj.

0 Likes

#10

Any workaround to alternatively modify the object?

0 Likes

#11

All three of the methods there should have worked in 8.0.5 and shouldn’t need a workaround. At this point you’d probably have better luck contacting support so they can take a look and see if there’s something else that is missing from the script.

0 Likes

#12

Solved from my side: I created a custom wrapper class.
I am looking forward to seeing your fixes.

0 Likes