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


Python SearchKey.extract_search_type方法代码示例

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


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

示例1: check

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import extract_search_type [as 别名]
    def check(my):
        if my.mode == 'export_matched':
            from tactic.ui.panel import TableLayoutWdg
            
            table = TableLayoutWdg(search_type=my.search_type, view=my.view,\
                show_search_limit='false', search_limit=-1, search_view=my.search_view,\
                search_class=my.search_class, simple_search_view=my.simple_search_view, init_load_num=-1)
            table.handle_search()
            search_objs = table.sobjects
            my.selected_search_keys = SearchKey.get_by_sobjects(search_objs, use_id=True)
            return True

        for sk in my.input_search_keys:
            st = SearchKey.extract_search_type(sk)
            if st not in my.search_type_list:
                my.search_type_list.append(st)

            id = SearchKey.extract_id(sk)
            if id == '-1':
                continue
            
            my.selected_search_keys.append(sk)
        
        if len(my.search_type_list) > 1:
            my.check_passed = False
            my.error_msg = 'More than 1 search type is selected. Please keep the selection to one type only.'
            return False

        if not my.search_type_list and my.mode == 'export_selected':
            my.check_passed = False
            my.error_msg = 'Search type cannot be identified. Please select a valid item.'
            return False
        return True
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:35,代码来源:data_export_wdg.py

示例2: execute

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

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

        sobj_id = input.get('id')
        if not sobj_id:
            sobj = Search.get_by_search_key(search_key)
            sobj_id = sobj.get_id()

        assert(sobj_id != None)

        # it is possible that the id is not an integer (ie MongoDb)
        # In this case, search_id cannot be used and this id is considered
        # a code
        if not search_code and not isinstance(sobj_id, int):
            search_code = sobj_id

        search_type = SearchKey.extract_search_type(search_key)
        
        # find the old sobject
        if sobj_id != -1:
            search = Search("sthpw/sobject_list")
            search.add_filter( "search_type", search_type )
            if search_code:
                search.add_filter( "search_code", search_code )
            else:
                search.add_filter( "search_id", sobj_id )
            sobject = search.get_sobject()
        else:
            sobject = None
        
        
        if input.get("is_delete") == True:
            if sobject:
                sobject.delete()
            return

        if not sobject:
            sobject = SearchType.create("sthpw/sobject_list")


        if not search_type.startswith("sthpw/"):
            project_code = Project.extract_project_code(search_type)
        else:
            project = "admin"

        sobject.set_value("project_code", project_code)



        caller = my.get_caller()

        data = set()

        data.update( my.cleanup(caller.get_value("code", no_exception=True) ))
        data.update( my.cleanup(caller.get_value("name", no_exception=True) ))
        data.update( my.cleanup(caller.get_value("description", no_exception=True) ))
        data.update( my.cleanup(caller.get_value("keywords", no_exception=True) ))

        # extra columns to add
        columns = []
        for column in columns:
            data.append( my.cleanup(caller.get_value(column) ))

        
        keywords = " ".join(data)
        sobject.set_value("keywords", keywords)

        sobject.set_parent(caller)
        sobject.commit(triggers=False)
开发者ID:nuxping,项目名称:TACTIC,代码行数:74,代码来源:global_search_trigger.py

示例3: execute

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

        self.handle_keywords()


        input = self.get_input()
        search_key = input.get("search_key")
        search_code = input.get('search_code')

        sobj_id = input.get('id')
        sobj = Search.get_by_search_key(search_key)


        # Why not user caller???? 
        caller = self.get_caller()

        # see if this sobject is the list of sobjects that need to be in the
        # sobject list
        search_types = ProjectSetting.get_value_by_key("global_search/search_types")
        if search_types:
            search_types = search_types.split(",")
            if sobj and sobj.get_base_search_type() not in search_types:
                return

        
        if not sobj_id:
            sobj_id = sobj.get_id()

        assert(sobj_id != None)

        # it is possible that the id is not an integer (ie MongoDb)
        # In this case, search_id cannot be used and this id is considered
        # a code
        if not search_code and not isinstance(sobj_id, int):
            search_code = sobj_id

        search_type = SearchKey.extract_search_type(search_key)

        input_search_type = input.get("search_type")
        base_search_type = input_search_type.split("?")[0]

        # find the old sobject list entry
        if sobj_id != -1:
            search = Search("sthpw/sobject_list")
            search.add_filter( "search_type", search_type )
            if search_code:
                search.add_filter( "search_code", search_code )
            else:
                search.add_filter( "search_id", sobj_id )
            sobject = search.get_sobject()
        else:
            sobject = None


        # delete the sobject list
        if input.get("is_delete") == True:
            if sobject:
                sobject.delete()
            return

        if not sobject:
            sobject = SearchType.create("sthpw/sobject_list")
            sobject.set_auto_code()

        if not search_type.startswith("sthpw/"):
            project_code = Project.extract_project_code(search_type)
        else:
            project = "admin"

        sobject.set_value("project_code", project_code)



        # build up a data set for sobject list
        data = set()

        data.update( self.cleanup(caller.get_value("code", no_exception=True) ))
        data.update( self.cleanup(caller.get_value("name", no_exception=True) ))
        data.update( self.cleanup(caller.get_value("description", no_exception=True) ))
        data.update( self.cleanup(caller.get_value("keywords", no_exception=True) ))

        # commit the information
        keywords = " ".join(data)
        sobject.set_value("keywords", keywords)

        sobject.set_parent(caller)
        sobject.commit(triggers=False)
开发者ID:mincau,项目名称:TACTIC,代码行数:89,代码来源:global_search_trigger.py

示例4: _test_dir_naming

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

        # change to the test dir naming class
        my.sobj.set_value('dir_naming_cls', 'pyasm.biz.naming_test.TestDirNaming')
        my.sobj.commit()

        # 1. try a different search_type unittest/person
        version = 9
        code = 'phil2'
        process = 'model'
        type = 'main'
        context = 'modeling'

        asset = SearchType.create( 'unittest/person' )
        asset.set_value("code",code)
        asset.set_value("name_first", "Philip")
        asset.commit()

        # change a different input file name
        file_obj = File(File.SEARCH_TYPE)
        # due to new restriction of set_sobject_value().. we can't use it any more
        #file_obj.set_sobject_value(asset)
        sk = SearchKey.get_by_sobject(asset, use_id =True)
        st = SearchKey.extract_search_type(sk)
        sid = SearchKey.extract_id(sk)
        file_obj.set_value('search_type', st)
        file_obj.set_value('search_id', sid)
        file_obj.set_value('file_name','some_maya_model.mb') 
        file_obj.set_value('type', type)
        file_obj.set_value('base_type', 'file')
        file_obj.commit()

        virtual_snapshot = Snapshot.create_new()
        virtual_snapshot_xml = '<snapshot process=\'%s\'><file type=\'%s\' file_code=\'%s\'/></snapshot>' % (process, type, file_obj.get_code())
        virtual_snapshot.set_value("snapshot", virtual_snapshot_xml)
        virtual_snapshot.set_value("context", context)

        virtual_snapshot.set_sobject(asset)
        virtual_snapshot.set_value("version", version)
        
       
        

        Project.set_project('unittest')
        dir_naming = Project.get_dir_naming()
        dir_naming.set_sobject(asset)
        dir_naming.set_snapshot(virtual_snapshot)
        dir_naming.set_file_object(file_obj)
        dir_name = dir_naming.get_dir()
        expected_dir_name = '/assets/phil2/mb.main/v009'
        expected_dir_name2 = '/phil2/mb.main/v009'
        my.assertEquals(expected_dir_name, dir_name)
        
        lib_paths = virtual_snapshot.get_all_lib_paths()
        sand_paths = virtual_snapshot.get_all_lib_paths(mode='sandbox')
        client_paths = virtual_snapshot.get_all_lib_paths(mode='client_repo')
       
        base_dir = Config.get_value("checkin", "asset_base_dir", sub_key='default')
        sand_base_dir = dir_naming.get_base_dir(protocol='sandbox')
        client_base_dir = dir_naming.get_base_dir(protocol='client_repo')
       

        my.assertEquals(lib_paths[0].startswith('%s%s'%(base_dir, expected_dir_name2)), True)
        my.assertEquals(sand_paths[0].startswith('%s%s'%(sand_base_dir[0], expected_dir_name2)), True)
        my.assertEquals(client_paths[0].startswith('%s%s'%(client_base_dir[0], expected_dir_name2)), True)

        # 2  get_preallocated_path
        # set version 1 here since it's the first snapshot for this sobject. 
        # without a virtual file_object, the file_name is empty, and so the dir ma.maya is now .maya
        my.assertEquals("phil/.maya/v001", my.get_preallocated_dir()) 
        
        # switch back to regular file naming
        my.sobj.set_value('file_naming_cls', 'pyasm.biz.naming_test.TestFileNaming')
        my.sobj.commit()

        my.assertEquals("phil/ma.maya/v001", my.get_preallocated_dir()) 
开发者ID:0-T-0,项目名称:TACTIC,代码行数:78,代码来源:naming_test.py

示例5: execute

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

        notification = self.kwargs.get('sobject_dict')
        search_key = notification.get('__search_key__')
        event = notification.get('event')
        parts  = event.split('|')
        if len(parts) < 2:
            raise TacticException('event should be in the form of {action}|{search_type}, e.g. update|sthpw/task or update|sthpw/task|status')
        orig_search_type = parts[1]
        search_type_obj  = SearchType.get(orig_search_type)
        sobject = SearchType.create(orig_search_type)

       
            
        self.sobjects.append(sobject)

        search_type = SearchKey.extract_search_type(search_key)
        search_id = notification.get('id')
        columns = search_type_obj.get_columns(orig_search_type)
        for column in columns:
            type = search_type_obj.get_column_type(orig_search_type,column)
            if column == 'search_type':
                value = search_type
            elif column == 'search_id':
                value = search_id
            elif column == 'project_code':
                value = Project.get_project_code()
            elif column in ['assigned', 'login']:
                value = Environment.get_user_name()
            elif type in ['integer','float','number']:
                value = 100
            elif type == 'timestamp':
                value = '20110101'
            else:
                value = '%s_test'%column
            try:
                sobject.set_value(column, value)
            except:
                continue


        notification_stype = notification.get('search_type')
        if notification_stype:
            sobject.set_value("search_type",  notification_stype)

        # some dummy output
        output = {'id': sobject.get_id()}

        notification_process = notification.get('process')
        if notification_process:
            if 'process' in columns:
                sobject.set_value("process", notification_process)
        try:
            triggers = Trigger.call(sobject, event, output=output, forced_mode='same process,same transaction', process = notification_process, search_type = notification_stype)
            if triggers:
                for idx, trigger in enumerate(triggers):
                    self.add_description('%s. %s' %(idx+1, trigger.get_description()))
            else:
                raise TacticException('No notification trigger is fired. Possible mismatched project_code for this notification entry.')
        except Exception, e:
            raise
            raise Exception(e.__str__())
开发者ID:mincau,项目名称:TACTIC,代码行数:64,代码来源:notification_cmd.py

示例6: get_display

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

        search_key = my.kwargs.get("search_key")
        msg = None
        base_search_type = SearchKey.extract_search_type(search_key)
        sobject = SearchKey.get_by_search_key(search_key)
        process_div = DivWdg()
        process_div.add_style('padding-top: 10px')

        if base_search_type  in ['sthpw/task', 'sthpw/note']:
            my.process = sobject.get_value('process')
            my.context = sobject.get_value('context')
            if not my.process:
                my.process = ''

            parent = sobject.get_parent()
            if parent:
                search_key = SearchKey.get_by_sobject(parent)
            else:
                msg = "Parent for [%s] not found"%search_key
            
        else:
            my.process = my.kwargs.get('process')

        
        top = my.top
        top.add_class('spt_simple_checkin')
        top.add_color("background", "background")
        top.add_styles("position: relative")

        content = DivWdg(msg)
        top.add(content)
        #content.add_border()
        #content.add_color("background", "background3")
        #content.add_color("color", "background3")
        content.add_style("width: 600px")
        content.add_styles("margin-left: auto; margin-right: auto;")
        content.add_style("height: 200px")

        from tactic.ui.widget import CheckinWdg
        content.add_behavior( {
            'type': 'load',
            'cbjs_action': CheckinWdg.get_onload_js()
        } )


        button_div = DivWdg()
        
        content.add(process_div)

        content.add(button_div)
        button = IconWdg(title="Check-In", icon=IconWdg.CHECK_IN_3D_LG)

        title = Common.get_display_title(my.checkin_action)
        button.add_attr('title', title)


        button_div.add(button)
        button_div.set_box_shadow("1px 1px 1px 1px")
        button_div.add_style("width: 60px")
        button_div.add_style("height: 60px")
        button_div.add_style("float: left")
        button_div.add_style("background: white")
        button_div.add_class("hand")

        button_div.add_style("padding: 2px 3px 0 0")
        button_div.add_style("margin: 20px 60px 20px 200px")
        button_div.add_style("text-align: center")

        button_div.add("Check-in")

        # to be consistent with Check-in New File
        if my.process:
            checkin_process = my.process
        else:
            # Dont' specify, the user can choose later in check-in widget
            checkin_process = ''
        button.add_behavior( {
            'type': 'click_up',
            'search_key': search_key,
            'process': checkin_process,
            'context': my.context,
            'cbjs_action': '''
            var class_name = 'tactic.ui.widget.CheckinWdg';
            var applet = spt.Applet.get();


            spt.app_busy.show("Choose file(s) to check in")


            var current_dir = null;
            var is_sandbox = false;
            var refresh = false
            var values = spt.checkin.browse_folder(current_dir, is_sandbox, refresh);
            if (!values) {
                spt.app_busy.hide();
                return;
            }

            var file_paths = values.file_paths;
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:103,代码来源:simple_checkin_wdg.py


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