v8.1
Trying to build a couple functions that will allow users to save runtime configurations (e.g. table filtering/columns/sorting/etc) into a DB so they can be sticky between sessions. I have a decent working prototype using copy.deepcopy()
in a view's Startup & Shutdown scripts on a single table component.
Now I'd like to move this to a project function so it can be used in many places, something like saveProp(comp,prop)
and restoreProp(comp,prop)
, where the function takes care of building the named query parameters out of the user credentials and supplied properties, comp
is an object referencing the component whose properties are being saved/restored, and prop
is a string value pointing to the property to save, e.g. props.filters
for a table.
I've been using Scripting reference parent property with parameter - Ignition - Inductive Automation Forum for ideas...
I have a few questions/problems:
- I'm hoping to keep script execution on the client as much as possible, since our client count may get pretty large and I don't want to burden the gateway. Are project library scripts executed on the client or the gateway?
- When my test view calls the project function, I'm getting an error:
AttributeError: 'com.inductiveautomation.perspective.gateway.script' object has no attribute 'getattr'
This is the project function:
def propGet (comp, prop):
props = comp.getattr(comp, prop)
print "props: %s" %(props)
This is the calling script, attached to a button on the same view as an alarm status table:
def runAction(self, event):
comp = self.getSibling("AlarmStatusTable")
system.perspective.print("comp: %s" %(comp))
project.functions.propGet(comp, 'props.filters.active.states')
The output console shows this from the calling script:
comp: com.inductiveautomation.perspective.gateway.script.ComponentModelScriptWrapper$SafetyWrapper@153dd4d
Not sure I understand why the component reference includes gateway.script
when it's coming from an event script on a button.
Why is getattr()
failing?
.