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


Python Search.get_search_type_obj方法代码示例

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


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

示例1: _get_target_span

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_search_type_obj [as 别名]
 def _get_target_span(my):
     # get the target span
     search = Search(my.container_cls)
     my._order_search(search)
     groups = search.get_sobjects()
     if groups:
         my.container_sobj = groups[0]
     
     target_span = SpanWdg(css='med')
     group_table = Table(my.GROUP_TABLE_NAME, css='table')
     group_table.add_style('width','30em')
     group_table.add_col(css='small')
     group_table.add_col(css='small')    
     group_table.add_col()    
         
     target_span.add(group_table)
     group_table.add_row_cell(search.get_search_type_obj()\
         .get_description(), "heading")
     checkbox = CheckboxWdg()
     checkbox.set_option("onclick", \
         "a=new Elements('container_ids');a.toggle_all(this);")
     group_table.add_row()
     group_table.add_cell(checkbox)
     col_name = group_table.get_next_col_name() 
     
     toggle_control = HiddenRowToggleWdg(col_name=col_name, is_control=True, auto_index=True)
   
     group_table.add_cell(toggle_control)
     group_table.add_cell('MASTER CONTROL')
     
     remove_cmd = HiddenWdg(SObjectGroupCmd.REMOVE_CMD)
     my.add(remove_cmd)
     for group in groups:
         group_table.add_row()
         checkbox = CheckboxWdg("container_ids")
         checkbox.set_option("value", group.get_primary_key_value() )
         
         toggle = HiddenRowToggleWdg(col_name, auto_index=True)
         toggle.store_event()
      
         group_details = ItemInContainerWdg( group, my.item_sobj, my.item_cls, my.grouping_cls )
        
         # set the target content of the toggle
         toggle.set_static_content(group_details)
        
         group_table.add_cell( checkbox )
         group_table.add_cell( toggle, add_hidden_wdg=True )
         group_table.add_cell( group.get_description())
         num_items = group_details.get_num_items()
         if num_items:
             td = group_table.add_cell( "( %s )" % num_items, 'no_wrap')
             td.add_color(color)
         else:
             group_table.add_blank_cell()
    
     
     return target_span
开发者ID:0-T-0,项目名称:TACTIC,代码行数:59,代码来源:sobject_group_wdg.py

示例2: _test_schema

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_search_type_obj [as 别名]

#.........这里部分代码省略.........
        # add bunch of dummy initial tasks to the person
        initial_tasks = Task.add_initial_tasks(my.person, 'task')

        # check status_log static trigger
        single_task = initial_tasks[0]
        from pyasm.search import Search

        to_status = Search.eval('@GET(sthpw/status_log.to_status)', sobjects=[single_task], single=True)
        my.assertEquals(to_status, "Assignment")
        single_task.set_value('status', "Test Done")
        single_task.commit(triggers=True)
        

        ExpressionParser.clear_cache() 
        to_status = Search.eval("@GET(sthpw/status_log['@ORDER_BY','id desc'].to_status)", sobjects=[single_task], single=True)
        
        my.assertEquals(to_status, "Test Done")

        # get tasks with get_all_children()
        tasks = my.person.get_all_children("sthpw/task")
        my.assertEquals(len(initial_tasks), len(tasks) )

        
        # get notes with get_all_children()
        Note.create(my.person, "test note", context='default')
        Note.create(my.person, "test note2", context='default2')
        notes = my.person.get_all_children("sthpw/note")
        my.assertEquals(2, len(notes) )

        #relationship
        schema = Schema.get()
        if Project.get_by_code('sample3d'):
            relationship = schema.get_relationship('prod/asset','sthpw/snapshot')
            my.assertEquals(relationship, 'search_code')
            #my.assertEquals(relationship, 'search_type')

            relationship = schema.get_relationship('prod/asset','sthpw/task')
            my.assertEquals(relationship, 'search_code')
            #my.assertEquals(relationship, 'search_type')

            relationship = schema.get_relationship('prod/shot','sthpw/note')
            my.assertEquals(relationship, 'search_code')
            #my.assertEquals(relationship, 'search_type')

        relationship = schema.get_relationship('sthpw/file','sthpw/snapshot')
        my.assertEquals(relationship, 'code')
        relationship = schema.get_relationship('sthpw/project_type','sthpw/project')
        my.assertEquals(relationship, 'code')

        relationship = schema.get_relationship('unittest/car','unittest/house')
        my.assertEquals(relationship, None)

        # test parent filter search in sample3d
        if Project.get_by_code('sample3d'):
            from pyasm.prod.biz import *
            Project.set_project('sample3d')

            shot = Shot.get_by_code('RC_001_001')
            if not shot:
                shot = Shot.create('RC_001_001', 'Some test shot')
            asset = SearchType.create('prod/asset')
            asset.set_value('code','unittest010')
            asset.set_value('name','unittest010')
            asset.commit()
            for x in xrange(3):
                ShotInstance.create(shot, asset, 'unittest_veh_001', unique=False) 
            
            instances = ShotInstance.get_by_shot_and_asset(shot, asset)
            parent_type = 'prod/shot'
            parent_search = Search(parent_type)
            parent_search.add_filter('code','RC_001_001')
        
            search = Search('prod/shot_instance') 
            search.add_filter('asset_code', asset.get_code())
            # we want the base here
            sobject_type = search.get_search_type_obj().get_base_key()

            schema = Schema.get()
            relationship = schema.get_relationship(sobject_type, parent_type)
            parents = parent_search.get_sobjects()
            if parents:
                if relationship in ["code", "id", "search_type"]:
                    search.add_relationship_filters(parents) 
                    
            sobjects = search.get_sobjects()
            my.assertEquals(len(instances), len(sobjects))

            
            relationship_attrs = schema.get_relationship_attrs('sthpw/transaction_log','sthpw/sobject_log')
            rev_relationship_attrs = schema.get_relationship_attrs('sthpw/sobject_log','sthpw/transaction_log')
            for attrs in [ relationship_attrs,  rev_relationship_attrs]:
                my.assertEquals(attrs.get('from_col'), 'transaction_log_id')
                my.assertEquals(attrs.get('to_col'), 'id')
                my.assertEquals(attrs.get('from'), 'sthpw/sobject_log')
                my.assertEquals(attrs.get('to'), 'sthpw/transaction_log')
                my.assertEquals(attrs.get('relationship'), 'id')
                my.assertEquals(attrs.get('disabled'), None)


        Project.set_project('unittest')
开发者ID:funic,项目名称:TACTIC,代码行数:104,代码来源:biz_test.py

示例3: init

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_search_type_obj [as 别名]
    def init(my):
        
 
        my.item_cls = my.kwargs.get('left_search_type')
        my.container_cls = my.kwargs.get('right_search_type')
        my.grouping_cls  = my.kwargs.get('search_type')

        my.item_sobj = my.container_sobj = None 
        
        # List the items
        search = Search(my.item_cls)
        my._order_search(search)    
        
        items = search.get_sobjects()
        if items:
            my.item_sobj = items[0]
        #select = MultiSelectWdg("item_ids")
        #select.set_search_for_options(search,"login", "get_full_name()")

        user_span = SpanWdg(css='med')
        
        user_table = Table(css='table')
        user_table.add_style("margin-left: 6px")
        user_table.set_max_width()
        user_table.add_col(css='small')
        user_table.add_col()
        
        user_table.add_style("min-width: 14em")
        user_table.add_row_cell(search.get_search_type_obj()\
            .get_description(), "heading")

        for item in items:
            user_table.add_row()
            checkbox = CheckboxWdg("item_ids")
            checkbox.set_option("value", item.get_primary_key_value() )
            user_table.add_cell( checkbox )

            project_code = item.get_value("project_code", no_exception=True)
            if project_code:
                user_table.add_cell( "[ %s ]" % project_code )
            else:
                user_table.add_cell( "[ * ]" )

            user_table.add_cell( item.get_description() )
        user_span.add(user_table)

        # control widget in the middle
        control_div = DivWdg()
        control_div.add_style('padding: 100px 10px 0 10px')

        button = IconSubmitWdg(my.ADD_LABEL, "stock_insert-slide.png", True)
        button.add_style('padding: 2px 30px 4px 30px')
        control_div.add(button)
        
        
        main_table = Table(css='collapse')
        main_table.set_max_width()
        main_table.add_row(css='plain_bg')
        main_table.add_cell(user_span, 'valign_top')
        td = main_table.add_cell(control_div, 'valign_top')
        td.add_style('width','12em')
        main_table.add_cell(my._get_target_span(), 'valign_top')

        my.add(main_table)
    
        # register command here
        if my.item_sobj and my.container_sobj:
            marshaller = WebContainer.register_cmd("pyasm.widget.SObjectGroupCmd")
            marshaller.set_option("grouping_search_type", my.grouping_cls)
            marshaller.set_option("item_foreign_key", my.item_sobj.get_foreign_key())
            marshaller.set_option("container_foreign_key", my.container_sobj.get_foreign_key())
开发者ID:0-T-0,项目名称:TACTIC,代码行数:73,代码来源:sobject_group_wdg.py

示例4: init

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

        web = WebContainer.get_web()
        search_type = web.get_form_value("search_type")
        search_ids = web.get_form_values("search_ids")

        download_types = web.get_form_values("download_types")

        search = Search(search_type)
        sobjects = []

        if search_ids:
            search.add_where("id in (%s)" % ", ".join(search_ids))
            sobjects = search.do_search()

        if not sobjects:
            message = HtmlElement.p("No %s to download." % search.get_search_type_obj().get_title())
            message.set_class("warning")
            my.add(message)
            return

        download_wdg = DownloadWdg()
        my.add(download_wdg)

        outer_div = DivWdg(css="admin_main")
        table = Table()
        table.set_class("table")

        # add download buttons

        widget = HtmlElement.div()
        # button = SubmitWdg("Download All")
        # widget.add(button)
        button = SubmitWdg("Download Selected")
        widget.add(button)
        tr, th = table.add_row_header(widget)
        th.add_style("text-align: center")

        # add all of the
        # widget = HtmlElement.div()
        # widget.add("<b>Download options:</b>")
        # for type in download_types:
        #    widget.add( CheckboxWdg(type) )
        #    widget.add( type)
        # tr, th = table.add_row_header(widget)
        # th.add_style("text-align: center")

        # add all of the sobjects
        col = 0
        for sobject in sobjects:

            if col == 0 or col % 3 == 0:
                table.add_row()

            search_id = sobject.get_id()

            icon_wdg = ThumbWdg()
            icon_wdg.set_name("snapshot")
            icon_wdg.set_sobject(sobject)

            div = HtmlElement.div()
            div.set_style("background-color: #f0f0f0")
            div.set_style("height: 100%")

            checkbox = CheckboxWdg("download_files")
            checkbox.set_option("value", "%s|%s" % (search_type, search_id))
            div.add(checkbox)
            if sobject.has_value("code"):
                div.add("<b>%s</b>" % sobject.get_value("code"))
            div.add("<br/>")

            div.add(icon_wdg)

            if sobject.has_value("code"):
                div.add(sobject.get_value("description"))

            td = table.add_cell(div)
            td.add_style("height: 120px")
            td.add_style("widget: 200px")

            col += 1

        outer_div.add(table)

        my.add(outer_div)
开发者ID:hellios78,项目名称:TACTIC,代码行数:87,代码来源:sobject_upload_wdg.py


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