Perspective Shared Script Session Props

Hello Everyone,

I am attempting to get some information about the perspective session from a shared script. Is there a way to access the session props from the system scripts library? I have tried system.perspective.getSessionInfo, but it gives a list of all the sessions. I tried using to lookup the correct session, but that function is not in the perspective scope. (I am also interested in the gateway address, but system.util.getGatewayAddress is also not in perspective scope for some reason.) I know I can pass the session object from a component scope, but that would require a lot of refactoring. Is that really the only way?

To get information about a specific session which is invoking the project script, you’ll need to pass the session into the script as an argument. I know you’re trying to avoid the refactor, but if you want that info then you need to pass something which has that info.

def my_proj_func(session):

Passing the session object is the only supported way. There is a gross hack you can do, but as mentioned in the thread, don’t expect support or be surprised if it breaks suddenly on upgrade.

1 Like

Always fun to see myself in a link about unsupported or non recommended techniques (:

This is promising, however it seems that it has broken already. I’m running 8.1.8 and getting this error when attempting that solution: com.inductiveautomation.ignition.common.script.JythonExecException: ImportError: No module named perspective

I would only expect it to work if invoked from a Perspective calling context, but even then it’s possible that classloader restrictions on the gateway are such it won’t work anyways.