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


Python SearchKey.get_by_sobject方法代码示例

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


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

示例1: get_display

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

        my.context = ''
        sobject = my.get_current_sobject()

        if sobject.get_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 = ''


            sobject_mode = my.kwargs.get("sobject_mode")
            if not sobject_mode:
                sobject_mode = "parent"
            #sobject_mode = "connect"
            if sobject_mode == "parent":
                parent = sobject.get_parent()
            elif sobject_mode == "connect":
                parent = Search.eval("@SOBJECT(connect)", sobject, single=True)
            elif sobject_mode == "expression":
                expression = "???"
                parent = Search.eval("@SOBJECT(connect)", sobject, single=True)
            else:
                parent = sobject

            if not parent:
                return DivWdg()

            search_key = SearchKey.get_by_sobject(parent)
        else:
            my.process = my.get_option('process')
            if not my.process:
                my.process = "publish"
            search_key = SearchKey.get_by_sobject(sobject)


        #my.behavior['process'] = my.process
        #my.behavior['context'] = my.context
        #my.behavior['search_key'] = search_key

        # set the atrs
        div = super(CheckinButtonElementWdg, my).get_display()
        div.add_attr("spt_process", my.process)
        div.add_attr("spt_context", my.context)
        div.add_attr("spt_search_key", search_key)

        return div
开发者ID:nuxping,项目名称:TACTIC,代码行数:50,代码来源:table_element_wdg.py

示例2: add_sobject_to_cache

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_sobject [as 别名]
    def add_sobject_to_cache(self, sobject):
        '''add an sobject to the cache.  This is useful if a new sobject
        has been inserted and it is too expensive to have to recache the entire
        table just for this one entry'''

        # make sure this sobject's search type is the same as the search type 
        # for this cache
        search_type = sobject.get_base_search_type()
        assert search_type == self.search_type


        # FIXME: add to all of the caches
        for key, cache in self.caches.items():
            if key == 'search_key':
                # add to the search_key cache
                search_key = SearchKey.get_by_sobject(sobject)
                cache[search_key] = sobject

            elif key == 'code':
                # add to the code cache
                code = sobject.get_code()
                cache[code] = sobject

            else:
                value = sobject.get_value(key)
                cache[value] = sobject

        # make sure this cache is set to dirty so other processes update
        self.make_dirty()
开发者ID:mincau,项目名称:TACTIC,代码行数:31,代码来源:cache.py

示例3: execute

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_sobject [as 别名]
    def execute(self):
        self.search_key_list = self.kwargs.get('search_key_list')
        web = WebContainer.get_web()
        skip_duplicated = web.get_form_value('skip_duplicated') == 'on'
        pipeline_mode = web.get_form_value('pipeline_mode')

        sobjects = SearchKey.get_by_search_keys(self.search_key_list)
        count = 0
        offset = 0
        for sobject in sobjects:
            if isinstance(sobject, Task):
                raise TacticException('Creation of task for [Task] is not allowed')
            sk = SearchKey.get_by_sobject(sobject)
            if not sobject.has_value('pipeline_code'):
                #raise TacticException('Creation of task is not allowed for item with no pipeline_code attribute.')
                pipeline_code = '__default__'
                sobject.set_value("pipeline_code", pipeline_code)
            else:
                pipeline_code = sobject.get_value('pipeline_code')
            input_name = '%s|task_process'% pipeline_code
            
            contexts = []
            process_names = web.get_form_values(input_name)
            process_names = [name for name in process_names if name]
            if pipeline_mode == 'context':
                # when pipeline_mode is context, we only specify contexts
                # in add_initial_tasks
                contexts = process_names[:]
                process_names = []
            tasks = Task.add_initial_tasks(sobject, sobject.get_value('pipeline_code'),
                    processes=process_names, contexts=contexts, skip_duplicate=skip_duplicated, mode=pipeline_mode, start_offset=offset)

            count += len(tasks)
            offset += 5
        self.add_description("%s Tasks added in total." % count)
开发者ID:mincau,项目名称:TACTIC,代码行数:37,代码来源:task_wdg.py

示例4: get_section_wdg

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

        parent_key = SearchKey.get_by_sobject(sobject)

        section_id = "wow"
        title = ""
        view = "children"
        target_id = "sobject_relation"

        kwargs = {
            'section_id': section_id,
            'title': title,
            'view': view,
            'target_id': target_id,
            'width': '125',
            'parent_key': parent_key
        }
        section_div = DivWdg()
        section_div.add_style("display: block")
        section_div.set_id(section_id)
        section_div.set_attr('spt_class_name', "tactic.ui.panel.ChildrenBookmarkMenuWdg")
        for name, value in kwargs.items():
            if name == "config":
                continue
            section_div.set_attr("spt_%s" % name, value)

        section_wdg = SObjectChildrenMenuWdg(**kwargs)
        section_div.add(section_wdg)
        return section_div
开发者ID:0-T-0,项目名称:TACTIC,代码行数:31,代码来源:search_type_panel_wdg.py

示例5: add_header

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_sobject [as 别名]
    def add_header(self, table, title):
        table.add_style('width', '50em')
        
        parent_st = self.kwargs.get('parent_search_type')
        parent_sid =  self.kwargs.get('parent_search_id')
        parent_context = ''
        parent_version = ''

        sobj = Search.get_by_id(parent_st, parent_sid)
        sobj_code = 'New'
        sobj_title = ''
        if sobj:
            sobj_code = sobj.get_code()
            sobj_title = sobj.get_search_type_obj().get_title()
            if isinstance(sobj, Snapshot):
                parent_context = sobj.get_context()
                parent_version = sobj.get_version()
        th = table.add_header( "Add Submission for %s [%s]" % (sobj_title, sobj_code))
        th.set_attr("colspan", "2")
        hidden = HiddenWdg('parent_search_type', parent_st )
        th.add(hidden)
        hidden = HiddenWdg('parent_search_id', parent_sid )
        th.add(hidden)
        
        hidden = HiddenWdg('parent_context', parent_context )
        th.add(hidden)

        hidden = HiddenWdg('parent_version', parent_version )
        th.add(hidden)
        
        if sobj:
            hidden = HiddenWdg('parent_search_key', SearchKey.get_by_sobject(sobj) )
            th.add(hidden)
开发者ID:mincau,项目名称:TACTIC,代码行数:35,代码来源:submission_wdg.py

示例6: get_display

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


        div = DivWdg()

        sobject = my.get_current_sobject()
        search_key = SearchKey.get_by_sobject(sobject)

        if sobject.is_admin():
            return "ADMIN"

        icon = IconButtonWdg("Global Permissions", IconWdg.EDIT)

        icon.add_behavior( {
            "type": "click_up",
            "cbjs_action": "spt.popup.get_widget(evt, bvr)",
            "options": {
                "class_name": "tactic.ui.panel.SecurityManagerWdg",
                "title": "Permisssion Manager",
                "popup_id": "Permission Manager"

            },
            "args": {
                "search_key": search_key
            }
        } )

        div.add(icon)

        return div
开发者ID:0-T-0,项目名称:TACTIC,代码行数:32,代码来源:security_manager_wdg.py

示例7: get_action_html

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_sobject [as 别名]
    def get_action_html(my):
        search_key = SearchKey.get_by_sobject(my.sobjects[0])
        behavior_submit = {
            'type': 'click_up',
            'cb_fire_named_event': 'append_pressed',
            'element_names': my.element_names,
            'search_key': search_key,
            'input_prefix': my.input_prefix

        }
        behavior_cancel = {
            'type': 'click_up',
            'cb_fire_named_event': 'preclose_edit_popup',
            'cbjs_postaction': "spt.popup.destroy( spt.popup.get_popup( $('edit_popup') ) );"
        }
        button_list = [{'label':  "%s/Close" % my.mode.capitalize(),
            'bvr': behavior_submit},
            {'label':  "Cancel", 'bvr': behavior_cancel}]        
        edit_close = TextBtnSetWdg( buttons=button_list, spacing =6, size='large', \
                align='center',side_padding=10)
        
       
        div = DivWdg()
        div.add_styles('height: 35px; margin-top: 10px;')
       
        div.center()
        div.add(edit_close)

        return div
开发者ID:funic,项目名称:TACTIC,代码行数:31,代码来源:edit_wdg.py

示例8: get_display

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

        sobject = my.get_current_sobject()

        my.search_key = SearchKey.get_by_sobject(sobject)
    
        div = DivWdg()
        div.add_class("hand")

        title = "Show Item Details"
        if my.widget:
            widget = my.widget
        else:
            widget = IconButtonWdg(title=title, icon=IconWdg.ZOOM)


        code = sobject.get_code()
        name = sobject.get_value("name", no_exception=True)
        if not name:
            name = code


        widget.add_behavior( {
        'type': 'click_up',
        'search_key': my.search_key,
        'code': code,
        'name': name,
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.tools.TaskDetailPanelWdg';
        var kwargs = {
            search_key: bvr.search_key,
        };

        var mode = '';
        var layout = bvr.src_el.getParent(".spt_tool_top");
        if (layout != null) {
            mode = 'tool'
        }

        if (mode == 'tool') {
            spt.app_busy.show("Loading ...");
            var layout = bvr.src_el.getParent(".spt_tool_top");
            var element = layout.getElement(".spt_tool_content");
            spt.panel.load(element, class_name, kwargs);
            spt.app_busy.hide();
        }
        else {
            var element_name = "detail_"+bvr.code;
            var title = "Detail ["+bvr.name+"]";
            spt.tab.add_new(element_name, title, class_name, kwargs);
        }
        '''
        } )


        div.add(widget)

        return div
开发者ID:pombredanne,项目名称:TACTIC,代码行数:61,代码来源:sobject_detail_wdg.py

示例9: get_no_icon_wdg

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_sobject [as 别名]
    def get_no_icon_wdg(my, missing=False):
        sobject = my.get_current_sobject()
        if not sobject:
            return ''

        div = my.top
        div.add_style("position: relative")
        div.add_style("margin: 3px")
        div.add_class("spt_thumb_top")

        div.set_id( "thumb_%s" %  sobject.get_search_key() )
        icon_size = my.get_icon_size()

        if icon_size:
            div.add_style("%s: %s" % (my.aspect, icon_size) )

        if missing:
            img = HtmlElement.img(ThumbWdg.get_missing_image())
        elif sobject.get_value("_is_collection", no_exception=True):
            img = HtmlElement.img("/context/icons/mime-types/folder2.jpg")
        else:
            img = HtmlElement.img(ThumbWdg.get_no_image())

        img.add_class("spt_image")


        #from tactic.ui.table import SObjectDetailElementWdg
        #detail = SObjectDetailElementWdg()
        #detail.set_widget(img)
        #detail.set_sobject(sobject)
        #div.add(detail)

        div.add(img)
        div.add_class("hand")
        if my.SQL_ERROR:
            warning_div = DivWdg('<i>-- preprocess error --</i>')
            warning_div.add_styles('position: absolute; z-index: 100; float: left; top: 0; left: 0; font-size: smaller;')
            div.add_style('position: relative')
            div.add(warning_div)

        search_key = SearchKey.get_by_sobject(sobject)
        code = sobject.get_code()
       
        
        detail = my.get_option("detail")
        if detail != 'false':
            my.add_icon_behavior(div, sobject)

        unit = None
        if isinstance(icon_size, basestring):
            icon_size, unit = my.split_icon_size(icon_size)

            img.add_style("%s: 100%%" % my.aspect )
        else:
            img.add_style("%s: %s" % (my.aspect, my.get_icon_size()) )
            img.add_style("min-%s: 15px" % my.aspect)

        return div
开发者ID:asmboom,项目名称:TACTIC,代码行数:60,代码来源:file_wdg.py

示例10: get_custom_layout_wdg

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

        content_div = DivWdg()

        from tactic.ui.panel import CustomLayoutWdg
        layout = CustomLayoutWdg(view=layout_view)
        content_div.add(layout)

        for widget in my.widgets:
            name = widget.get_name()
            if my.input_prefix:
                widget.set_input_prefix(my.input_prefix)

            layout.add_widget(widget, name)



        search_key = SearchKey.get_by_sobject(my.sobjects[0], use_id=True)
        search_type = my.sobjects[0].get_base_search_type()


        element_names = my.element_names[:]
        for element_name in my.skipped_element_names:
            element_names.remove(element_name)


        config_xml = my.kwargs.get("config_xml")
        bvr =  {
            'type': 'click_up',
            'mode': my.mode,
            'element_names': element_names,
            'search_key': search_key,
            'input_prefix': my.input_prefix,
            'view': my.view,
            'config_xml': config_xml
        }

        if my.mode == 'insert':
            bvr['refresh'] = 'true'
            # for adding parent relationship in EditCmd
            if my.parent_key:
                bvr['parent_key'] = my.parent_key


        hidden_div = DivWdg()
        hidden_div.add_style("display: none")
        content_div.add(hidden_div)

        hidden = TextAreaWdg("__data__")
        hidden_div.add(hidden)
        hidden.set_value( jsondumps(bvr) )

        show_action = my.kwargs.get("show_action")
        if show_action in [True, 'true']:
            content_div.add( my.get_action_html() )

        return content_div
开发者ID:funic,项目名称:TACTIC,代码行数:59,代码来源:edit_wdg.py

示例11: get_item_div

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_sobject [as 别名]
    def get_item_div(self, sobject):
        ''' get the item div the sobject'''
        top = DivWdg()
        top.add_style("padding: 3px 2px")
        top.add_class("spt_drop_item")
        top.add_class("SPT_DROP_ITEM")


        item_div = DivWdg()
        top.add(item_div, "item_div")
        item_div.add_style("text-overflow: ellipsis")
        item_div.add_style("white-space: nowrap")
        item_div.add_style("width: 80%")
        item_div.add_attr('title','Click to remove')
        item_div.add_style("display", "inline-block")
        item_div.add_style("vertical-align", "top")
        item_div.add_style("overflow", "hidden")


        icon_div = DivWdg()
        top.add(icon_div)
        icon = IconWdg(icon="BS_REMOVE")
        icon_div.add(icon)
        icon_div.add_behavior( {
            'type': 'click_up',
            #'cbjs_action': '''spt.dg_table_action.sobject_drop_remove(evt,bvr)'''
            'cbjs_action': '''spt.drop.sobject_drop_remove(evt,bvr)'''
        } )
        icon.add_style("opacity: 0.3")
        icon_div.add_class("hand")
        icon_div.add_style("display", "inline-block")
        icon_div.add_style("vertical-align", "top")
        #icon_div.add_border()


        #self.menu.set_over(item_div, event="mousein")
        #self.menu.set_out(top, event="mouseleave")


        # set this as the place for the display value to go
        item_div.add_class("spt_drop_display_value")

        add_icon = True
        ExpressionParser.clear_cache()
        if sobject:
            if add_icon:
                self._add_icon(sobject, item_div)

            if self.display_expr:
                display_value = Search.eval(self.display_expr, sobjects = sobject, single=True)
            else:
                display_value = sobject.get_display_value()
            if isinstance(display_value, list):
                display_value = display_value[0]
            item_div.add( display_value )
            self.values.append( SearchKey.get_by_sobject(sobject) )
        return top
开发者ID:mincau,项目名称:TACTIC,代码行数:59,代码来源:drop_element_wdg.py

示例12: get_no_icon_wdg

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_sobject [as 别名]
    def get_no_icon_wdg(my, missing=False):
        sobject = my.get_current_sobject()
        if not sobject:
            return ''

        div = my.top
        div.add_style("position: relative")
        div.add_style("margin: 3px")
        div.add_class("spt_thumb_top")

        div.set_id( "thumb_%s" %  sobject.get_search_key() )
        icon_size = my.get_icon_size()

        if icon_size:
            div.add_style("%s: %s" % (my.aspect, icon_size) )

        if missing:
            img = HtmlElement.img(ThumbWdg.get_missing_image())
        else:
            img = HtmlElement.img(ThumbWdg.get_no_image())

        img.add_class("spt_image")


        #from tactic.ui.table import SObjectDetailElementWdg
        #detail = SObjectDetailElementWdg()
        #detail.set_widget(img)
        #detail.set_sobject(sobject)
        #div.add(detail)

        div.add(img)
        div.add_class("hand")
        if my.SQL_ERROR:
            warning_div = DivWdg('<i>-- preprocess error --</i>')
            warning_div.add_styles('position: absolute; z-index: 100; float: left; top: 0; left: 0; font-size: smaller;')
            div.add_style('position: relative')
            div.add(warning_div)

        search_key = SearchKey.get_by_sobject(sobject)
        code = sobject.get_code()
       
        
        detail = my.get_option("detail")
        if detail != 'false':
            my.add_icon_behavior(div, sobject)

        if type(icon_size) == types.StringType and icon_size.endswith("%"):
            img.add_style("%s: 100%%" % my.aspect )
        else:
            img.add_style("%s: %spx" % (my.aspect, my.get_icon_size()) )
        img.add_style("min-%s: 15px" % my.aspect)

        return div
开发者ID:southpawtech,项目名称:TACTIC-DEV,代码行数:55,代码来源:file_wdg.py

示例13: get_history_wdg

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

        # special for snapshots as well
        content_id ='summary_hist_%s' %sobject.get_id()
        title_id = 'hist_head_%s' %sobject.get_id()
        hist_head = DivWdg()
        hist_head.add_style('height','1.8em')
        hist_title = my._get_title_span("Checkin History")
        
        swap_wdg = my._get_swap_wdg(title_id)

        """
        dyn_load = AjaxLoader(display_id=content_id)

        dyn_load.add_element_name('parent_key')
        args_dict = {'search_type': sobject.get_search_type()}
        args_dict['search_id'] = sobject.get_id()
        dyn_load.set_load_class('pyasm.flash.widget.FlashAssetHistoryWdg', load_args=args_dict)
        on_script = dyn_load.get_on_script(load_once=True)

        """
        # Load once feature is not implemented yet
        parent_key = SearchKey.get_by_sobject(sobject)
        dynamic_class = 'pyasm.flash.widget.FlashAssetHistoryWdg'
        on_script = '''
                spt.panel.is_refreshing = true;
                var el_id = '%s';
                spt.panel.show_progress(el_id);
                var kwargs = {'parent_key': '%s'};
                setTimeout( function() {
                    spt.panel.load(el_id, '%s', kwargs, {}, false);
                    spt.panel.is_refreshing = false;
                }, 100 );
                ''' % (content_id, parent_key, dynamic_class)

        on_script = "%s;spt.show_block('%s')"  %(on_script, content_id)
        toggle_script = "spt.toggle_show_hide('%s')" %content_id

        swap_wdg.add_action_script(on_script, toggle_script)

        hist_head.add(swap_wdg)
        hist_head.add(hist_title)

        my.add_title_style(hist_title, title_id, swap_wdg)
        
        hist_div = DivWdg(id=content_id)
        hist_div.add_style('display','none')
        
 
        return hist_head, hist_div
开发者ID:0-T-0,项目名称:TACTIC,代码行数:52,代码来源:asset_detail_wdg.py

示例14: get_table

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_sobject [as 别名]
    def get_table(my, sobject, snapshots):
        parent_key = SearchKey.get_by_sobject(sobject)
        table = TableLayoutWdg(
            table_id="snapshot_history_table",
            search_type="sthpw/snapshot",
            view="checkin_history",
            show_search_limit=False,
            show_gear=False,
            show_insert=False,
            parent_key=parent_key,
            mode="simple",
        )
        table.set_sobjects(snapshots)

        return table
        """
开发者ID:hellios78,项目名称:TACTIC,代码行数:18,代码来源:flash_asset_history_wdg.py

示例15: get_instance_wdg

# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_sobject [as 别名]
    def get_instance_wdg(self, instance_type):
        sorted_instances = self._get_sorted_instances()
        content_div = Widget()

        for instance in sorted_instances:
            item_div = self.get_item_div(instance)
            item_div.add_attr( "spt_search_key", SearchKey.get_by_sobject(instance) )
            item_div.add_class("spt_drop_item")

            # no need for that
            #item_div.add('&nbsp;')
            content_div.add(item_div)
        value_wdg = self.get_value_wdg()
        json = jsondumps(self.values)
        json = json.replace('"', '&quot;')
        value_wdg.set_value(json)

        return content_div
开发者ID:mincau,项目名称:TACTIC,代码行数:20,代码来源:drop_element_wdg.py


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