TACTIC Open Source
Expression value column widget problem - Printable Version

+- TACTIC Open Source (http://forum.southpawtech.com)
+-- Forum: TACTIC Open Source (http://forum.southpawtech.com/forumdisplay.php?fid=3)
+--- Forum: TACTIC Discussion (http://forum.southpawtech.com/forumdisplay.php?fid=4)
+--- Thread: Expression value column widget problem (/showthread.php?tid=95)

Pages: 1 2


Expression value column widget problem - EricTsuei - 04-14-2020

While I am using 'expression' widget in the column, I can use @GET(.name) to get the sobject's data

but I using 'expression value' widget in the column, I can't use @GET(.name) to do so, only get an empty list []. so how can I get the same sobject's data that I put in expression values?

and how can I use 'expression' widget to @GET(expression value column) 's value, I only get a complete expression string


RE: Expression value column widget problem - remkonoteboom - 04-15-2020

Expression value takes the "value" of the column and executes the expression in that value. This means that the value of the column has to be an expression.

So, if the name column contained:
@GET(.display_name)
in the database, then expression value would evaluate this and return the result.

This was meant to behave somewhat like a spreadsheet where each of the cells calculated values. To be honest, I have used expression value that often.

This is just an explanation of what expression value does. I am not completely sure I understand your question.


RE: Expression value column widget problem - EricTsuei - 04-16-2020

please see the attachment screenshot.

hope I explain it clearly. thanks.

there are 2 exp wdg,  "expression wdg" and "expression value wdg"

"expression wdg" defines expression in the column definition, eval them in each same column row. And can use @GET(.name)  get current data.

"expression value wdg" defines expression in the cell value,and can not use @GET(.name)  get data. only gets a empty list.  Only works  with {@GET(proj/stype["code","xxxxx00001"].name)}


RE: Expression value column widget problem - remkonoteboom - 04-16-2020

The display that defines the Expression Value is the following (in src/tactic/ui/table/expression_element_wdg.py


Code:
1141    def get_display(self):
1142
1143        sobject = self.get_current_sobject()
1144        if sobject.is_insert():
1145            return
1146
1147        value = self.get_value()
1148
1149        # assume the value is an expression
1150        try:
1151            value = Search.eval(value)
1152        except Exception as e:
1153            print(e.message)
1154            value = "Error [%s]" % value
1155
1156        return "%s" % value
1157


I think the problem you are facing is due to line 1151.  What you want it to be is the following:

Code:
1151            value = Search.eval(value, sobject)


Can you see if this change fixes your problem?

As I previously mentioned, I really haven't used this widget that much.  The difference is the current definition uses an absolute expression and the change turns it into a relative one.  I don't know which is better because I haven't really had any real world use cases.


RE: Expression value column widget problem - EricTsuei - 04-17-2020

I have try the code, and can use @GET(.name), but can't use @COUNT(vfx/asset) or @COUNT(vfx/shot) any more. is there some way do both of them?

for example. can I use exp value wdg some code like these :
@COUNT(vfx/asset["type",@GET(.name)])
or
@COUNT(vfx/asset["type",@GET(current_sobject.name)])


RE: Expression value column widget problem - EricTsuei - 04-17-2020

if this exp value wdg can do this, and it will be the most important wdg to easily sum or report anything on any tables.


RE: Expression value column widget problem - remkonoteboom - 04-17-2020

Ok, I think I understand.  This change will do what you want:


Code:
1150        try:
1151            env_sobjects = {
1152                'sobject': sobject
1153            }
1154            value = Search.eval(value, env_sobjects=env_sobjects)
1155        except Exception as e:
1156            print(e.message)
1157            value = "Error [%s]" % value


This will allow this expression:

@COUNT(vfx/asset['type',@GET(sobject.name)])

Note how the env_sobjects argument allow for extra sobjects to be named within the expression language.

Give it a try and if it works, could you put in a pull request on Github to make sure it goes in the version you want it to.  We will merge it up the various versions as needed.


RE: Expression value column widget problem - EricTsuei - 04-18-2020

yes,seems this code work perfect..
thank you.
but I am don't know how github pull request works, how should I do?


RE: Expression value column widget problem - remkonoteboom - 04-18-2020

In order to do a pull request, you would create your own fork of TACTIC on Github, make the changes in the code, commit, push and then create a pull request. It's pretty standard Github procedure. It's a great way to contribute changes to the source code (for anybody interested). This page describes it pretty well:

https://yangsu.github.io/pull-request-tutorial/

If not, then don't worry about it. Just tell me what version you need it in and we'll get it into all the versions up from that.


RE: Expression value column widget problem - EricTsuei - 04-21-2020

there's some bug with the code.

please see for the attachment.
seems the sobject gets a full list of entire stype, and every time I get is the first sobj's value, need use list id to get the current sobject.