当前位置: 首页>>代码示例>>Python>>正文


Python HtmlElement.eval_update方法代码示例

本文整理汇总了Python中pyasm.web.HtmlElement.eval_update方法的典型用法代码示例。如果您正苦于以下问题:Python HtmlElement.eval_update方法的具体用法?Python HtmlElement.eval_update怎么用?Python HtmlElement.eval_update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasm.web.HtmlElement的用法示例。


在下文中一共展示了HtmlElement.eval_update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import eval_update [as 别名]

#.........这里部分代码省略.........

        #print "last: ", last_timestamp

        # get out all of the search_keys
        client_keys = set()
        for id, values_list in updates.items():
            if isinstance(values_list, dict):
                values_list = [values_list]

            for values in values_list:
                handler = values.get("handler")
                if handler:
                    handler = Common.create_from_class_path(handler)
                    search_key = handler.get_search_key()
                else:
                    search_key = values.get("search_key")

                if search_key:
                    client_keys.add(search_key)

        # find all of the search that have changed
        changed_keys = set()
        for check_type in ['sthpw/change_timestamp', 'sthpw/sobject_log']:
            search = Search(check_type)
            search.add_filter("timestamp", last_timestamp, op=">")
            search.add_filters("search_type", ["sthpw/sobject_log", "sthpw/status_log"], op="not in")
            #print search.get_statement()
            changed_sobjects = search.get_sobjects()
            for sobject in changed_sobjects:
                search_type = sobject.get_value("search_type")
                search_code = sobject.get_value("search_code")
                if search_type.startswith("sthpw/"):
                    search_key = "%s?code=%s" % (search_type, search_code)
                else:
                    search_key = "%s&code=%s" % (search_type, search_code)
                changed_keys.add(u'%s'%search_key)

        intersect_keys = client_keys.intersection(changed_keys)

        #for x in client_keys:
        #    print x
        #print "---"
        #print "changed_keys: ", changed_keys
        #print "---"
        #print "intersect_keys: ", intersect_keys


        from pyasm.web import HtmlElement

        results = {}
        for id, values_list in updates.items():

            if isinstance(values_list, dict):
                values_list = [values_list]


            for values in values_list:

                handler = values.get("handler")
                if handler:
                    handler = Common.create_from_class_path(handler)
                    search_key = handler.get_search_key()
                else:
                    search_key = values.get("search_key")

                if search_key and search_key not in intersect_keys:
                    continue

                # evaluate any compare expressions
                compare = values.get("compare")
                if compare:
                    search_key = values.get("search_key")
                    if search_key:
                        sobject = Search.get_by_search_key(search_key)
                    else:
                        sobject = None
                    cmp_result = Search.eval(compare, sobject, single=True)
                    if cmp_result == True:
                        continue

                    # some randome value
                    value = "Loading ..."
                else:
                    value = HtmlElement.eval_update(values)

                if value == None:
                    continue
                results[id] = value

        my.info = {
            "updates": results,
            "timestamp": timestamp
        }


        #print "time: ", time.time() - start
        #print results


        return results
开发者ID:pombredanne,项目名称:TACTIC,代码行数:104,代码来源:dynamic_update_wdg.py

示例2: execute

# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import eval_update [as 别名]

#.........这里部分代码省略.........

                if search_key:
                    if isinstance(search_key, list):
                        search_key_set = set(search_key)
                    else:
                        search_key_set = set()
                        search_key_set.add(search_key)
                    client_keys.update(search_key_set)

                stype = values.get("search_type")
                if stype:
                    client_stypes.add(stype)

        # find all of the search that have changed
        changed_keys = set()
        changed_types = set()
        for check_type in ['sthpw/change_timestamp', 'sthpw/sobject_log']:
            search = Search(check_type)
            search.add_filter("timestamp", last_timestamp, op=">")
            search.add_filters("search_type", ["sthpw/sobject_log", "sthpw/status_log"], op="not in")
            changed_sobjects = search.get_sobjects()
            for sobject in changed_sobjects:
                search_type = sobject.get_value("search_type")
                search_code = sobject.get_value("search_code")
                if search_type.startswith("sthpw/"):
                    search_key = "%s?code=%s" % (search_type, search_code)
                else:
                    search_key = "%s&code=%s" % (search_type, search_code)
                changed_keys.add(u'%s'%search_key)
                changed_types.add(search_type)

        intersect_keys = client_keys.intersection(changed_keys)



        from pyasm.web import HtmlElement

        results = {}
        for id, values_list in updates.items():
            if isinstance(values_list, dict):
                values_list = [values_list]

            for values in values_list:

                handler = values.get("handler")
                if handler:
                    handler = Common.create_from_class_path(handler)
                    # handler can return a list of search_keys
                    search_key = handler.get_search_key()
                else:
                    search_key = values.get("search_key")

                stype = values.get("search_type")
                if search_key:
                    if isinstance(search_key, list):
                        search_key_set = set(search_key)
                    else:
                        search_key_set = set()
                        search_key_set.add(search_key)
                    
                    # filter for search_type first if it exists
                    # check if any search_key is contained in intersect_keys, skip if not 

                    if stype and stype in changed_types:
                        if len(intersect_keys  - search_key_set) == len(intersect_keys):
                            continue
                    elif len(intersect_keys  - search_key_set) == len(intersect_keys):
                        continue
                
                # evaluate any compare expressions
                compare = values.get("compare")
                if compare:
                    search_key = values.get("search_key")
                    if search_key:
                        sobject = Search.get_by_search_key(search_key)
                    else:
                        sobject = None
                    cmp_result = Search.eval(compare, sobject, single=True)
                    if cmp_result == True:
                        continue

                    # some value to display
                    value = "Loading ..."
                else:
                    value = HtmlElement.eval_update(values)

                if value == None:
                    continue
                
                results[id] = value

        my.info = {
            "updates": results,
            "timestamp": timestamp
        }



        #print "Dyn Cmd duration", time.time()  - start
        return results
开发者ID:0-T-0,项目名称:TACTIC,代码行数:104,代码来源:dynamic_update_wdg.py


注:本文中的pyasm.web.HtmlElement.eval_update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。