Using Expressions in Scripting

Using Expressions in Python - Server code

Expressions can be accessed directly through Python code. The expression language is often very convenient to quickly perform relatively complex searches quickly and easily.

To access the expressions in Python, you would use the following code:

from import ExpressionParser
parser = ExpressionParser()
expr = "@GET(prod/shot['code','chr001'].prod/"
result = parser.eval(expr)

It is often more convenient just to access it through the Search module:

from import Search
expr = "@GET(prod/shot['code','chr001'].prod/"
result = Search.eval(expr)

Using Expressions in Python - Client API code

To access the expressions in the Python Client API, you would use the following code:

server = TacticServerStub.get()
expr = "@GET(prod/shot['code','chr001'].prod/"
result = server.eval(expr)

When the expression language returns sobjects, these will be in the form of a dictionary like all other sobjects in the client API.

Using Expressions in Javascript - Client API code

To access the expressions in the Javascript Client API, you would use the following code:

var server = TacticServerStub.get()
expr = "@GET(prod/shot['code','chr001'].prod/"
var result = server.eval(expr)

Using Expressions in Widget Config

The main widget to use expressions is "tactic.ui.table.ExpressionElementWdg".

When using the ExpressionElementWdg, the starting point of the expression is automatically the SObject associated with the row. This allows you to use the shorthand form without having to filter.

<element name='code'>
  <display class='tactic.ui.table.ExpressionElementWdg'>

Using Expressions inline in HTML

When using the CustomLayoutWdg, inline expressions are supported using a [expr][/expr] tag formatting.

  <h2>There are [expr]@COUNT(prod/asset['asset_library', 'chr'])[/expr] Characters</h2>

Using Expressions in CustomLayoutWdg

The custom layout widget has a special html tag which can have html embedded within it. CustomLayoutWdg provides the ability to embed expressions within its html definition.

The following demonstrates a widget config using expressions:

        <?xml version='1.0' encoding='UTF-8'?>
    <tr><td>[expr]{@GET(.code)} : {@GET(.description)}[/expr]</td></tr>

Please refere to the CustomLayoutWdg in the Widget Reference documentation for more information on how to use the CustomLayoutWdg.