Config Info
Name Dashboards.T04custom.persistence
Version 2.0

Interface

get(variable) 
  • return the saved value of the variable variable
  • if not present in the cache this is loaded from a file in t04customdata
 set(variable,value,IronPython=True) 
  • set the value of the variable variable
  • the value is written to a file in in t04customdata
  • If IronPython is set to True, the value is loaded in the cache too.

Usage Example

In Dashboards

import sys sys.path.append(r"C:\Program Files (x86)\Tango04\Dashboards") testValue=1 from t04custom import persistence test=persistence.get("test") if test==None: Text="Variable Test is null, Value initialized to testValue %(testValue)s"%{'testValue':testValue} persistence.set("test",testValue) else: Text="Variable Test contains %(result)s"%{'result':test} 

 

In a normal python script

useful to load a dictionnary from an external source so that it can be used in the dashboard

if __name__ == "__main__": #import and other stuff print "Updating cached Dashboards dictionary Name->Uuid\n" from xml.dom.minidom import parse import os import re dashboards={} #load the dictionnary from external source for file in os.listdir(T04Path.T04DashboardsDashboardsPath): if re.search('t04panel$',file): print "Processing file %s\n"%file dom=parse(os.path.join(T04Path.T04DashboardsDashboardsPath,file)) dashboards[dom.getElementsByTagName("Panel")[0].attributes["Name"].value]=dom.getElementsByTagName("Panel")[0].attributes["Uuid"].value #keep it on a file so that is accessible inside the Dashboards persistence.set('Dashboards',dashboards,IronPython=False) 

 

Requirements

Depends On

Used by

 


Still have questions? We can help. Submit a case to Technical Support.

Last Modified On: October 18, 2018