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


Python Search.add_project_filter方法代码示例

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


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

示例1: get_by_search_type

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_project_filter [as 别名]
    def get_by_search_type(cls, search_type, project_code=''):
        # make sure this is a be search type
        assert search_type
        search_type_obj = SearchType.get(search_type)
        if not search_type_obj:
            return []
        search_type = search_type_obj.get_base_key()

        cache_key = "%s|%s" % (search_type, project_code)


        # commenting out until we have a full implementation of
        # project pipelines
        """
        search = Search("config/pipeline")
        if search_type:
            search.add_filter("search_type", search_type)
        search.add_project_filter(project_code)
        pipelines = cls.get_by_search(search, cache_key, is_multi=True)
        """

        
        search = Search("sthpw/pipeline")
        if search_type:
            search.add_filter("search_type", search_type)
        search.add_project_filter(project_code)
        pipelines = cls.get_by_search(search, cache_key, is_multi=True)
        if not pipelines:
            return []
        for pipe in pipelines:
            code = pipe.get_code()
            cls.cache_sobject('sthpw/pipeline|%s' %code, pipe)
        return pipelines
开发者ID:0-T-0,项目名称:TACTIC,代码行数:35,代码来源:pipeline.py

示例2: get_db_triggers

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

        site_triggers = Container.get(cls.KEY)
        if site_triggers == None:
            # find all of the triggers
            search = Search("sthpw/trigger")
            search.add_project_filter()
            site_triggers = search.get_sobjects()
            Container.put(cls.KEY, site_triggers)

        # find all of the project triggers
        from pyasm.biz import Project
        project_code = Project.get_project_code()
        key = "%s:%s" % (cls.KEY, project_code)
        project_triggers = Container.get(key)
        if project_triggers == None:
            if project_code not in ['admin','sthpw']:
                try:
                    search = Search("config/trigger")
                    project_triggers = search.get_sobjects()
                except SearchException, e:
                    print "WARNING: ", e
                    project_triggers = []
            else:
                project_triggers = []
            Container.put(key, project_triggers)
开发者ID:blezek,项目名称:TACTIC,代码行数:28,代码来源:trigger.py

示例3: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_project_filter [as 别名]
    def get_display(my):
        pipeline_search = Search( Pipeline )
        if not my.search_type:
            search_type_option = my.get_option('search_type')
            if search_type_option:
                my.search_type = search_type_option
        if my.search_type:
            pipeline_search.add_filter( 'search_type', my.search_type )
        pipeline_search.add_order_by( 'code' )
        project_code = Project.get_project_code()
        pipeline_search.add_project_filter(project_code)

        my.set_search_for_options( pipeline_search, 'code', 'code' )

        return super(PipelineSelectWdg, my).get_display()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:17,代码来源:prod_input_wdg.py

示例4: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_project_filter [as 别名]
    def execute(self):
        input = self.get_input()

        search_key = input.get("search_key")
        task = Search.get_by_search_key(search_key)
        parent = task.get_parent()
        if not parent:
            raise TacticException("Task parent not found.")

        # get the definition of the trigger
        trigger_sobj = self.get_trigger_sobj()
        data = trigger_sobj.get_value("data")
        try:
            data = jsonloads(data)
        except:
            raise TacticException("Incorrect formatting of trigger [%s]." % trigger_sobj.get_value("code"))

        # check against source status if present 
        src_status = data.get("src_status")
        if src_status:
            task_status = task.get_value("status")
            if task_status != src_status:
                return

        process_names = data.get("output")
        if not process_names:
            return

        # only create new task if another of the same
        # process does not already exist
        search = Search("sthpw/task")
        search.add_filters("process", process_names)
        search.add_parent_filter(parent)
        search.add_project_filter()
        tasks = search.get_sobjects()
        existing_processes = [x.get_value("process") for x in tasks]
       
        for process in process_names:
            if process in existing_processes:    
                continue
            else:
                Task.create(parent, process, start_date=None, end_date=None)
开发者ID:mincau,项目名称:TACTIC,代码行数:44,代码来源:pipeline_task_trigger.py

示例5: get_display

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


        state = my.get_state()
        search_type = state.get("search_type")
        sobj = my.get_current_sobject()

        if search_type:
            st = search_type
        else:
            
            st = sobj.get_base_search_type()
        # for inline insert, this should proceed
        #if not sobj:
        #    return ''
        
        st_suffix = st.split('/', 1)
    
        if len(st_suffix) == 2:
            st_suffix = st_suffix[1]
        
        search = Search('sthpw/pipeline')
        search.add_op_filters([('search_type','EQ', '/%s' %st_suffix)])

        # takes into account site-wide pipeline
        search.add_project_filter(show_unset=True)
        sobjects = search.get_sobjects()

        codes = [x.get_code() for x in sobjects]

        if my.get_option("use_code") in [True, 'true']:
            names = codes
        else:

            names = []
            for x in sobjects:
                name = x.get_value("name")
                if not name:
                    name = x.get_value("code")
                names.append(name)



        select = SelectWdg(my.get_input_name())
        select.add_empty_option("-- Default --")
        select.set_option("values", codes)
        select.set_option("labels", names)
        if sobj:
            value = sobj.get_value(my.get_name())
            if value:
                select.set_value(value)

        else: 
            # only for inline
            #behavior =  { 'type': 'click',
            #       'cbjs_action': 'spt.dg_table.select_wdg_clicked( evt, bvr.src_el );'}
            #select.add_behavior(behavior)
            pass
        

        return select
开发者ID:nuxping,项目名称:TACTIC,代码行数:63,代码来源:pipeline_input_wdg.py

示例6: handle_search

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_project_filter [as 别名]
    def handle_search(my):
        login = my.kwargs.get("login")
        project_code = my.kwargs.get("project")

        my.start_date = datetime(my.year, my.month, 1)
        next_month = my.month+1
        next_year = my.year
        if next_month > 12:
            next_month = 1
            next_year += 1

        my.end_date = datetime(next_year, next_month, 1)


        search = Search("sthpw/task")
        if login:
            search.add_filter("assigned", login)
        if project_code:
            if project_code == "$PROJECT":
                search.add_project_filter()
            else:
                search.add_filter("project_code", project_code)


        search.add_filter("bid_end_date", my.start_date, op=">")
        search.add_filter("bid_end_date", my.end_date, op="<")
        my.task_count = search.get_count()
        my.tasks = search.get_sobjects()
        my.tasks_count = {}
        for task in my.tasks:
            date = task.get_value("bid_end_date")
            date = parser.parse(date)
            date = datetime(date.year, date.month, date.day)

            count = my.tasks_count.get(str(date))
            if not count:
                count = 0

            count += 1
            my.tasks_count[str(date)] = count



        search = Search("sthpw/snapshot")
        if login:
            search.add_filter("login", login)
        if project_code:
            if project_code == "$PROJECT":
                search.add_project_filter()
            else:
                search.add_filter("project_code", project_code)



        search.add_filter("timestamp", my.start_date, op=">")
        search.add_filter("timestamp", my.end_date, op="<")
        my.snapshot_count = search.get_count()
        my.snapshots = search.get_sobjects()
        my.snapshots_count = {}
        for snapshot in my.snapshots:
            date = snapshot.get_value("timestamp")
            date = parser.parse(date)
            date = datetime(date.year, date.month, date.day)

            count = my.snapshots_count.get(str(date))
            if not count:
                count = 0
            count += 1
            my.snapshots_count[str(date)] = count




        search = Search("sthpw/task")
        if login:
            search.add_filter("assigned", login)
        if project_code:
            if project_code == "$PROJECT":
                search.add_project_filter()
            else:
                search.add_filter("project_code", project_code)
        search.add_filter("timestamp", my.start_date, op=">")
        search.add_filter("timestamp", my.end_date, op="<")
        my.task_count = search.get_count()




        search = Search("sthpw/note")
        if login:
            search.add_filter("login", login)
        if project_code:
            if project_code == "$PROJECT":
                search.add_project_filter()
            else:
                search.add_filter("project_code", project_code)

        search.add_filter("timestamp", my.start_date, op=">")
        search.add_filter("timestamp", my.end_date, op="<")
        my.note_count = search.get_count()
#.........这里部分代码省略.........
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:103,代码来源:sobject_calendar_wdg.py

示例7: get_by_event

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_project_filter [as 别名]
    def get_by_event(cls, event, process=None):
        '''get a list of triggers by event'''
        
        site_triggers = Container.get(cls.KEY)
        if site_triggers == None:
            # find all of the triggers
            search = Search("sthpw/trigger")
            search.add_project_filter()
            site_triggers = search.get_sobjects()

            Container.put(cls.KEY, site_triggers)

        # find all of the project triggers
        from pyasm.biz import Project
        project_code = Project.get_project_code()
        key = "%s:%s" % (cls.KEY, project_code)
        project_triggers = Container.get(key)
        if project_triggers == None:
            if project_code not in ['admin','sthpw']:
                search = Search("config/trigger")
                project_triggers = search.get_sobjects()
            else:
                project_triggers = []
            Container.put(key, project_triggers)


        triggers = []
        triggers.extend(site_triggers)
        triggers.extend(project_triggers)

        #for trigger in triggers:
        #    print trigger.get_search_key()

        search_type = None

        event_triggers = []
        for trigger in triggers:

            # determin trigger process
            trigger_process = trigger.get_value("listen_process", no_exception=True)
            if not trigger_process:
                trigger_process = trigger.get_value("process", no_exception=True)

            # determine if the process matches the trigger process
            if trigger_process and not process:
                continue
            if process and not trigger_process:
                continue
            if trigger_process and process and trigger_process != process:
                continue


            # determine the search_type
            trigger_stype = trigger.get_value("search_type", no_exception=True)
            if trigger_stype and not search_type:
                continue
            if search_type and not trigger_stype:
                continue
            if trigger_stype and search_type and trigger_stype != search_type:
                continue


            #print event, trigger_process, process,trigger.get_id()

            if trigger.get_value("event") == event:
                event_triggers.append(trigger)

        return event_triggers
开发者ID:blezek,项目名称:TACTIC,代码行数:70,代码来源:trigger.py

示例8: get_display

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

        #parent_class = "TabWdg"
        my.parent_class = my.parent_wdg.__class__.__name__
        if my.parent_class == "TbodyWdg":
            my.parent_class = "TableWdg"
        elif my.parent_class == "MayaTabWdgImpl":
            my.parent_class = "TabWdg"

        # get the key
        if my.parent_class == "TabWdg":
            key = my.parent_wdg.get_tab_path()
        elif my.parent_class == "TableWdg":
            key = "%s|%s" % (my.search_type, my.parent_wdg.get_view() )
        else:
            key = my.parent_wdg.get_name()

        # set sobjects from the parent, if there are any
        my.sobjects = my.parent_wdg.get_sobjects()
        
        # search for these
        from pyasm.search import Search
        search = Search("sthpw/widget_extend")
        search.add_project_filter()
        search.add_filter("type", my.parent_class)
        search.add_filter("key", key)
        extends = search.get_sobjects()

        for extend in extends:
            xml = extend.get_xml_value("data")
            index = xml.get_value("widget/@index")
            if index:
                index = int(index)
            else:
                index = None

            title = xml.get_value("widget/@name")

            nodes = xml.get_nodes("widget/widget")
            if nodes:
                widget = Widget()
                for node in nodes:
                    node_string = Xml.get_node_xml(node)
                    child_widget = CustomXmlWdg(node_string)
                    if not child_widget:
                        continue
                    if my.sobjects:
                        child_widget.set_sobjects(my.sobjects)
                    widget.add(child_widget)


            else:
                widget = CustomXmlWdg(xml.to_string())
                if my.sobjects:
                    widget.set_sobjects(my.sobjects)

            
            if my.parent_class == 'TableWdg':
                table_element = widget.get_display_widget()
                table_element.set_parent_wdg(my.parent_wdg)
            my.parent_wdg.add(widget, title, index=index)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:63,代码来源:tab_wdg.py

示例9: get_group_wdg

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

        div = DivWdg()

        title_wdg = DivWdg()
        div.add(title_wdg)
        title_wdg.add_style("padding: 5px")
        title_wdg.add_style("font-weight: bold")
        title_wdg.add_style("font-size: 14px")
        title_wdg.add_gradient("background", "background")
        title_wdg.add("Users")
        title_wdg.add_style("min-width: 200px")

        filtered_groups = my.kwargs.get("groups")
        if isinstance(filtered_groups, basestring):
            filtered_groups = filtered_groups.split("|")

        search = Search("sthpw/login_group")
        if filtered_groups:
            search.add_filters("login_group", filtered_groups)

        security = Environment.get_security()
        if not security.check_access("builtin", "view_site_admin", "allow"):
            search.add_filter("login_group", "admin", op="!=")
        search.add_project_filter()

        groups = search.get_sobjects()

        groups_div = DivWdg()
        div.add(groups_div)
        for group in groups:

            group_div = DivWdg()
            groups_div.add(group_div)

            title_div = DivWdg()
            group_div.add(title_div)
            title_div.add_color("background", "background3")
            title_div.add_color("color", "color3")
            title_div.add_style("margin-top: 5px")
            title_div.add_style("padding: 2px")

            swap = SwapDisplayWdg()
            title_div.add(swap)
            swap.add_style("float: left")

            title = DivWdg(group.get_value("login_group"))
            title_div.add(title)
            # title.add_style("float: left")
            title.add_style("font-weight: bold")
            title.add_style("padding-top: 2px")

            content_div = DivWdg()
            group_div.add(content_div)

            SwapDisplayWdg.create_swap_title(title, swap, div=content_div, is_open=True, action_script=None)

            logins = group.get_logins()
            logins_div = my.get_logins_wdg(logins)
            content_div.add(logins_div)
            content_div.add_style("padding-left: 15px")

        return div
开发者ID:hellios78,项目名称:TACTIC,代码行数:65,代码来源:schedule_wdg.py


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