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


Python Search.get_by_id方法代码示例

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


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

示例1: create_sobject_log

# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import get_by_id [as 别名]
    def create_sobject_log(cls, log, transaction_data=None):

        if not transaction_data:
            transaction_data = log.get_value("transaction")

        # log a reference to each sobject affected
        already_logged = {}
        xml = Xml()
        xml.read_string(transaction_data)
        nodes = xml.get_nodes("transaction/*")


        # list of sobjects not logged
        not_logged = set([
            'sthpw/transaction_log',
            'sthpw/clipboard',
            'sthpw/sobject_log',
            'sthpw/file',
            'sthpw/message',
            'sthpw/message_log',
        ])

        find_parent = set([
            'sthpw/snapshot',
            'sthpw/note',
            'sthpw/task'
        ])


        for node in nodes:
            node_name = xml.get_node_name(node)
            if node_name == "sobject":
                search_type = Xml.get_attribute(node,"search_type")
                search_type_obj = SearchType.get(search_type)


                if search_type_obj.get_base_key() in not_logged:
                    continue


                search_id = Xml.get_attribute(node,"search_id")
                search_code = Xml.get_attribute(node,"search_code")

                if search_code:
                    search_key = "%s?code=%s" % (search_type, search_code)
                else:
                    search_key = "%s|%s" % (search_type, search_id)


                if already_logged.get(search_key):
                    continue
                already_logged[search_key] = True

                # delete items are not presently logged ...
                # TODO: maybe they should be
                action = Xml.get_attribute(node,"action")
                if action == "delete":
                    continue

                if search_code:
                    sobject = Search.get_by_code(search_type, search_code)
                else:
                    sobject = Search.get_by_id(search_type, search_id)


                if sobject:
                    SObjectLog.create(sobject, log)
                else:
                    # record has been deleted
                    if search_code:
                        print("Skipped SObject log creation for [%s?code=%s]" %(search_type, search_code))
                    else:
                        print("Skipped SObject log creation for [%s|%s]" %(search_type, search_id))

                if search_type_obj.get_base_key() in find_parent:
                    try:
                        if sobject:
                            sobject = sobject.get_parent()
                    except (SearchException, SqlException):
                        # don't worry if this parent can't be found.
                        pass
                    if sobject:
                        SObjectLog.create(sobject, log)
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:85,代码来源:transaction_log.py


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