[BUG] tolist() broken in 8.0.5

Updated an existing project from 8.0.4 to 8.0.5. All my scripts that used .tolist() broke and gave error “object has no type .tolist()”. For example, grabbing the data from a table and using .tolist() on it. Reverted back to 8.0.4 and everything worked again.

Can you give us an example of code that broke? What were you calling tolist() on?

list = self.parent.parent.getChild(“Table”).props.data.tolist()

The document ‘wrapper’ objects got updated - this is unintentional fallout from that change. Rather than calling tolist(), you can just use the builtin list() function: list = list(self.parent.parent.getChild(“Table”).props.data) - but, with the improved wrappers in 8.0.5, you hopefully shouldn’t actually need to do that - most features of the list class should be implemented by the wrapper objects already.

2 Likes

On 8.0.6, I'm having issues using list() to get the Widgets list converted to a json string for the DB.

If I grab the item directly I get all the ArrayWrappers and ObjectWrappers. Doing a list() only seems to remove the ArrayWrapper but leaves the ObjectWrapper internally

Any ideas?

Try this, in the meantime - I need to come up with a better way to handle conversion to json (or, our jsonEncode function needs to get better at encoding objects)

from com.inductiveautomation.ignition.common import TypeUtilities
jsonObject = TypeUtilities.pyToGson(<yourobject>)
print jsonObject
1 Like

Not quite. Now it looks like this

{"site":{"value":"chico","quality":{"code":192},"timestamp":"Dec 17, 2019, 3:07:32 PM"},"userId":{"value":1,"quality":{"code":192},"timestamp":"Dec 17, 2019, 3:07:32 PM"}}

When I want it to look like this

{"site":"chico","userId":1}

It originally looked like this

{site=[chico, Good, Tue Dec 17 15:12:41 PST 2019 (1576624361477)], userId=[1, Good, Tue Dec 17 15:12:41 PST 2019 (1576624361477)]}

Can you share any more of what you’re doing/a code snippet? You shouldn’t really have to deal with qualified values much.

Sure. I simplified it for this post.

Here is the property on the view
image

Change Script
image

deserialize method from the StateMachine class
image

So if you make your property change script stateMachine = StateMachine.deserialize(TypeUtilities.pyToGson(currentValue.value)) you get the extra qualified value information?

You might just need to recurse down the qualified values yourself; at least in the short term.

Okay. I have to ask why is it different between a component referencing the property value vs the value of the property coming through the change script?

I’m not sure - I wasn’t party to the decision making back when the groundwork was first being laid for Perspective. It might just be a bug outright, although fixing it at this point risks backwards compatibility problems.

Here is the workaround solution that seems to work. I setup a second custom property I call “spy” that is bound to the first custom property. Then I setup my change script on the “spy” property that references my first property so that it will be in regular json and not qualified value json. This way I avoid using the currentValue parameter of the change script.

Thanks for the responses on this thread.

I downloaded the AdHoc Trends screen from the Ignition Exchange. Most of it works but there are a few places where it’s using “tolist” which is not working in 8.05+.

One specific place is in “root.Contents.Chart.TabContainer.Pens”. There’s a script on that which handles the “delete” checkbox for pens. Line 8 of that script reads “pens = self.view.custom.pens.tolist()” which is currently broken in 8.05.

I changed “pens = self.view.custom.pens.tolist()” to "
I changed the line to read “pens = list(view.custom.pens)” and the same on the next .tolist and it fixed it in 8.05 as suggested.

I assume it will break if I upgrade to 8.06. I typed this out so that anyone downloading that screen from Ignition Exchange knows how to fix it.