-->
当前位置:首页 > articles > 正文内容

Luz1个月前 (10-28)articles275

Is there a way to return a result from a walker without reporting it using jaseci

  • Shawn Jemmott 问题:
    • report: [{"response": "xyz"}];instead ofreport: ["jdsjdbjs","dndkfndkfn",{"response": "xyz"}];
  • 回答:
    • Yiping Kang - vote: 0
        If you need to return something from a walker to its caller, you can use
        has anchor
        in the walker being called. This will be "return" value of the walker spawn statement. For example,
    • walker B {  has anchor X;  X = 5;}walker A {  Y = spawn here walker::B;}
    • In this example,
      Y
      will be assigned the value of
      5
      when walker B finishes walking.
      If you are using the same walker in different scenarios where sometimes you need it to report and sometimes you don't. What I usually do is to just create a parameter for the walker, something like
      if_report
      and just report when it is set to True.
  • marsninja - vote: 0
    • Seems like it would be nice if Jac had some language features around this. But you can check out "report custom" support. Its described here https://docs.jaseci.org/docs/docs/Developing_with_JAC/Language_Features/report_custom.html (docs arn't very good atm). Also keep in mind that once you set
      report:custom
      = that exact jsonized object will be reported after the run. (You wont get the full walker dictionary that includes "report", "success", etc etc.
    • Also note the last executed
      report:custom
      will be the only report returned.
    • walker cust_report{    report:custom = {'a': 'b'}; }walker cust_report_neutralize{ # this walker will report nothing    report:custom = {'a': 'b'};    report:custom = null; }walker disengage_report{ # this walker will report {'a': 'b'}    disengage report:custom = {'a': 'b'};    report:custom = null; }
返回列表

上一篇:

下一篇:

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。