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


Python SearchKey.get_by_search_key方法代码示例

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


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

示例1: execute

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_key [as 别名]
    def execute(my):
        plugin = my.sobject

        web = WebContainer.get_web()
        value = web.get_form_value( my.get_input_name() )
        if not value:
            return
        src_search_keys = jsonloads(value)


        manifest = plugin.get_xml_value("manifest")

        top_node = manifest.get_node("manifest")

        for search_key in src_search_keys:
            sobject = SearchKey.get_by_search_key(search_key)

            node = manifest.create_element("sobject")

            # For now, a plugin must contain project specfic entries
            search_type = sobject.get_base_search_type()
            code = sobject.get_value("code")
            manifest.set_attribute(node, "search_type", search_type)
            manifest.set_attribute(node, "code", code)

            #search_key = SearchKey.get_by_sobject(sobject)
            #manifest.set_attribute(node, "search_key", search_key)

            manifest.append_child(top_node, node)

        plugin.set_value("manifest", manifest.to_string() )
        plugin.commit()
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:34,代码来源:plugin.py

示例2: init_kwargs

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_key [as 别名]
    def init_kwargs(my):
        """initialize kwargs"""
        state = my.kwargs.get("state")
        if state:
            parent_key = state.get("parent_key")
            if parent_key:
                my.sobject = SearchKey.get_by_search_key(parent_key)

        my.expression = my.get_option("expression")
        if not my.expression:
            my.expression = my.kwargs.get("expression")

        my.alt_expression = my.get_option("alt_expression")
        if not my.alt_expression:
            my.alt_expression = my.kwargs.get("alt_expression")

        my.mode = my.get_option("mode")
        if not my.mode:
            my.mode = my.kwargs.get("mode")
        if not my.mode:
            my.mode = "value"

        my.show_retired = my.get_option("show_retired")
        if not my.show_retired:
            my.show_retired = my.kwargs.get("show_retired")

        # default to False
        if my.show_retired == "true":
            my.show_retired = True
        else:
            my.show_retired = False

        my.enable_eval_listener = False
        if my.get_option("enable_eval_listener") in [True, "true", "True", "TRUE"]:
            my.enable_eval_listener = True
开发者ID:raidios,项目名称:TACTIC,代码行数:37,代码来源:expression_element_wdg.py

示例3: postprocess

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_key [as 别名]
    def postprocess(self):
        web = WebContainer.get_web()
        value = web.get_form_value( self.get_input_name() )
        if not value:
            return
        
        # get all fo the sobjects from the search keys
        instance_type = self.get_option("instance_type")
        
        # path is used for self-relating in an instance table
        src_path = self.get_option("path")

    
        #src_sobject = self.sobject

        search = Search(self.sobject.get_search_type())
        search.add_id_filter(self.sobject.get_id())
        src_sobject = search.get_sobject()

        # this is passed in from EditCmd in insert mode
        parent_key = self.get_option('parent_key')
        # in some rare cases we have project as the parent_key
        if parent_key and self.is_insert and 'sthpw/project' not in parent_key:
            # this is the parent
            dst_sobject = SearchKey.get_by_search_key(parent_key)

            # add all the new sobjects
            #instances = dst_sobject.get_related_sobject(instance_type)
            instance = SearchType.create(instance_type)
            instance.add_related_connection(src_sobject, dst_sobject, src_path=src_path)

            instance.commit()
开发者ID:mincau,项目名称:TACTIC,代码行数:34,代码来源:drop_element_wdg.py

示例4: handle_td

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_key [as 别名]
    def handle_td(self, td):
        sobj = self.get_current_sobject()
        parent = None
        
        value = sobj.get_value('process')
        td.add_attr('spt_input_value', value)

        if sobj.is_insert():
            state = self.get_state()
            parent_key = state.get('parent_key')
            if parent_key:
                parent = SearchKey.get_by_search_key(parent_key)
        else:
            # get the parent pipeline code
            try:
                parent = sobj.get_parent()
            except SObjectSecurityException as e:
                print "SObjectSecurityException raised for getting parent of [%s]" %sobj.get_code()
                pass
            except SearchException as e:
                if e.__str__().find('not registered') != -1:
                    pass
                elif e.__str__().find('does not exist for database') != -1:
                    pass    
                else:
                    raise
            except Exception as e:
                print "WARNING: ", e


        if parent:
            pipeline_code = parent.get_value("pipeline_code", no_exception=True)
            if pipeline_code:
                td.add_attr('spt_pipeline_code', pipeline_code)
开发者ID:mincau,项目名称:TACTIC,代码行数:36,代码来源:subcontext_wdg.py

示例5: get_files

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_key [as 别名]
    def get_files(my):

        paths = []

        # remember this here for now
        my.files = {}

        my.snapshots = {}


        search_key = my.kwargs.get("search_key")
        search_keys = my.kwargs.get("search_keys")
        if search_key:
            sobject = SearchKey.get_by_search_key(search_key)
            my.sobjects = [sobject]

        if search_keys:
            if isinstance(search_keys, basestring):
                search_keys = search_keys.replace("'", '"')
                search_keys = jsonloads(search_keys)
            my.sobjects = Search.get_by_search_keys(search_keys)

        if not my.sobjects:
            return []

        my.sobject = my.sobjects[0]


        for sobject in my.sobjects:
            sobject_paths = my.get_sobject_files(sobject)
            paths.extend(sobject_paths)

        return paths
开发者ID:blezek,项目名称:TACTIC,代码行数:35,代码来源:snapshot_files_wdg.py

示例6: check

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_key [as 别名]
    def check(my):
        search_key = my.kwargs.get('search_key')
        my.sobject = SearchKey.get_by_search_key(search_key)
        
        from pyasm.web import WebContainer
        web = WebContainer.get_web()

        my.old_password = web.get_form_value("old password")
        if isinstance(my.old_password, list):
            my.old_password = my.old_password[0]
        #encrypted = md5.new(my.old_password).hexdigest()
        encrypted = hashlib.md5(my.old_password).hexdigest()
        
        if encrypted != my.sobject.get_value('password'):
            raise UserException('Old password is incorrect.')
        my.password = web.get_form_value("password")
        if isinstance(my.password, list):
            my.password = my.password[0]


        if my.sobject == None:
            return UserException("Current user cannot be determined.")

        my.re_enter = web.get_form_value("password re-enter")
        if isinstance(my.re_enter, list):
            my.re_enter = my.re_enter[0]
        if my.re_enter != "" and my.re_enter != my.password:
            raise UserException( "Passwords must match. Please fill in the re-enter.")

        return True
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:32,代码来源:sign_out_cmd.py

示例7: handle_td

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_key [as 别名]
    def handle_td(self, td):
        sobject = self.get_current_sobject()
        parent = None
        if sobject.is_insert():
            parent_key = self.state.get('parent_key')
            if parent_key:
                parent = SearchKey.get_by_search_key(parent_key)
        else:
            try:
                parent = sobject.get_parent()
            except SObjectSecurityException as e:
                pass
            except SearchException as e:
                if e.__str__().find('not registered') != -1:
                    pass
                elif e.__str__().find('does not exist for database') != -1:
                    pass    
                else:
                    raise
            process = sobject.get_value('process')

            current_value = sobject.get_value(self.get_name())
            if current_value:
                value = '%s||%s'%(process, current_value)

                td.add_attr("spt_input_value",  value)


        if parent:
            td.set_attr("spt_pipeline_code", parent.get_value("pipeline_code", no_exception=True))
开发者ID:mincau,项目名称:TACTIC,代码行数:32,代码来源:task_wdg.py

示例8: handle_td

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_key [as 别名]
    def handle_td(my, td):
        sobj = my.get_current_sobject()
        parent = None

        value = sobj.get_value("process")
        td.add_attr("spt_input_value", value)

        if sobj.is_insert():
            state = my.get_state()
            parent_key = state.get("parent_key")
            if parent_key:
                parent = SearchKey.get_by_search_key(parent_key)
        else:
            # get the parent pipeline code
            try:
                parent = sobj.get_parent()
            except SObjectSecurityException, e:
                print "SObjectSecurityException raised for getting parent of [%s]" % sobj.get_code()
                pass
            except SearchException, e:
                if e.__str__().find("not registered") != -1:
                    pass
                elif e.__str__().find("does not exist for database") != -1:
                    pass
                else:
                    raise
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:28,代码来源:subcontext_wdg.py

示例9: execute

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_key [as 别名]
    def execute(my):

        input = my.get_input()
        search_key = input.get("search_key")

        sobj = SearchKey.get_by_search_key(search_key)
        login_group = sobj.get_value('login_group')
        sobj.set_value('code', login_group)

        sobj.commit(triggers=False)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:12,代码来源:login_group_trigger.py

示例10: add_to_selected

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_key [as 别名]
    def add_to_selected(cls, search_keys):
        # make sure the sobjects exist
        for search_key in search_keys:
            sobject = SearchKey.get_by_search_key(search_key)
            item = SearchType.create("sthpw/clipboard")
            item.set_user()

            item.add_related_sobject(sobject)
            item.set_value("category", "select")
            item.commit()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:12,代码来源:clipboard.py

示例11: execute

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_key [as 别名]
    def execute(self):
        web = WebContainer.get_web()
        value = web.get_form_value( self.get_input_name() )
        if not value:
            value = self.get_data()

        if not value:
            return


        src_search_keys = jsonloads(value)
        #print "xxx: ", type(src_search_keys), src_search_keys

        # get all fo the sobjects from the search keys
        #src_sobjects = SearchKey.get_by_search_keys(src_search_keys)
        instance_type = self.get_option("instance_type")
        # path is used for self-relating in an instance table
        src_path = self.get_option("path")

        src_sobjects = []
        src_instances = []
        for src_search_key in src_search_keys:
            src_sobject = SearchKey.get_by_search_key(src_search_key)

            if src_sobject.get_base_search_type() == instance_type:
                src_instances.append(src_sobject)
            else:
                src_sobjects.append(src_sobject)


        dst_sobject = self.sobject

        
        # get all of the current instances and see if any were removed
        instances = dst_sobject.get_related_sobjects(instance_type)
        for instance in instances:
            exists = False
            for src_instance in src_instances:
                if src_instance.get_search_key() == instance.get_search_key():
                    exists = True

            if not exists:
                instance.delete()


        # add all the new sobjects
        for src_sobject in src_sobjects:

            instance = SearchType.create(instance_type)
            instance.add_related_connection(src_sobject, dst_sobject, src_path=src_path)

            instance.commit()
开发者ID:mincau,项目名称:TACTIC,代码行数:54,代码来源:drop_element_wdg.py

示例12: init

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_key [as 别名]
 def init(my):
     sobject = None
     if not my.sobjects:
         """
         args = WebContainer.get_web().get_form_args()
         search_type = args['search_type']
         search_id = args['search_id']
         """
         search_key = my.kwargs.get('search_key')
         if search_key:
             sobject = SearchKey.get_by_search_key(search_key)
     else:
         sobject = my.sobjects[0]
         search_type = sobject.get_search_type()
         search_id = sobject.get_id()
     my.parent = sobject
开发者ID:0-T-0,项目名称:TACTIC,代码行数:18,代码来源:asset_detail_wdg.py

示例13: handle_td

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_key [as 别名]
 def handle_td(my, td):
     sobject = my.get_current_sobject()
     parent = None
     if sobject.is_insert():
         parent_key = my.state.get('parent_key')
         if parent_key:
             parent = SearchKey.get_by_search_key(parent_key)
     else:
         try:
             parent = sobject.get_parent()
         except SObjectSecurityException, e:
             pass
         except SearchException, e:
             if e.__str__().find('not registered') != -1:
                 pass
             elif e.__str__().find('does not exist for database') != -1:
                 pass    
             else:
                 raise
开发者ID:0-T-0,项目名称:TACTIC,代码行数:21,代码来源:task_wdg.py

示例14: get_files

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_key [as 别名]
    def get_files(self):

        paths = []

        # remember this here for now
        self.files = {}

        self.snapshots = {}


        search_key = self.kwargs.get("search_key")
        search_keys = self.kwargs.get("search_keys")
        if search_key:
            sobject = SearchKey.get_by_search_key(search_key)
            self.sobjects = [sobject]

        if search_keys:
            if isinstance(search_keys, basestring):
                search_keys = search_keys.replace("'", '"')
                search_keys = jsonloads(search_keys)
            self.sobjects = Search.get_by_search_keys(search_keys)

        if not self.sobjects:
            return []

        self.sobject = self.sobjects[0]


        for sobject in self.sobjects:
            
            if sobject.get_base_search_type() in ['sthpw/task', 'sthpw/note']:
                parent = sobject.get_parent()
                sobject_paths = self.get_sobject_files(parent)
                paths.extend(sobject_paths)

            else:
                sobject_paths = self.get_sobject_files(sobject)
                paths.extend(sobject_paths)


        return paths
开发者ID:mincau,项目名称:TACTIC,代码行数:43,代码来源:snapshot_files_wdg.py

示例15: execute

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_key [as 别名]
    def execute(my):

        search_key = my.search_key
        assert search_key

        sobject = SearchKey.get_by_search_key(search_key)
        xml = sobject.get_xml_value("access_rules")

        from pyasm.security import AccessRuleBuilder
        builder = AccessRuleBuilder(xml=xml)

        web = WebContainer.get_web()
        rules = web.get_form_values("rule")


        # sync the rules
        group = "builtin"
        group_default = 'deny'
        builder.add_default_rule(group, group_default)
        default_attr = builder.get_default(group)
        
        for item in permission_list:
            key = item.get('key')
            if key in rules:
                if default_attr == 'deny':
                    access = "allow"
                    builder.add_rule(group, key, access)
                else:
                    builder.remove_rule(group, key)
            else:
                if default_attr == 'deny':
                    builder.remove_rule(group, key)
                else:
                    access = "deny"
                    builder.add_rule(group, key, access)

        new_rules = builder.to_string()
        sobject.set_value("access_rules", new_rules)
        sobject.commit()
        my.add_description('Built-in access rules updated sucessfully!')
开发者ID:0-T-0,项目名称:TACTIC,代码行数:42,代码来源:security_manager_wdg.py


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