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


Python search.Search类代码示例

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


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

示例1: _test_time

    def _test_time(my):
        """ test timezone related behavior"""
        sobject = SearchType.create("sthpw/task")
        sobject.set_value("project_code", "unittest")
        sobject.set_value("bid_start_date", "2014-11-11 05:00:00")
        time = sobject.get_value("bid_start_date")
        my.assertEquals(time, "2014-11-11 05:00:00")

        sobject.commit()

        time = sobject.get_value("bid_start_date")
        my.assertEquals(time, "2014-11-11 05:00:00")
        from pyasm.search import DbContainer

        sql = DbContainer.get("sthpw")
        db_value = sql.do_query("SELECT bid_start_date from task where id = %s" % sobject.get_id())

        # 2014-11-11 00:00:00 is actually written to the database
        my.assertEquals(db_value[0][0].strftime("%Y-%m-%d %H:%M:%S %Z"), "2014-11-11 00:00:00 ")

        # an sType specified without a project but with an id could be a common human error
        # but it should handle that fine
        obj1 = Search.eval('@SOBJECT(unittest/person?project=unittest["id", "%s"])' % sobject.get_id(), single=True)
        obj2 = Search.eval('@SOBJECT(unittest/person?id=2["id", "%s"])' % sobject.get_id(), single=True)
        obj3 = Search.eval('@SOBJECT(sthpw/task?id=2["id", "%s"])' % sobject.get_id(), single=True)
        task = Search.eval('@SOBJECT(sthpw/task["id", "%s"])' % sobject.get_id(), single=True)

        # EST and GMT diff is 5 hours
        my.assertEquals(task.get_value("bid_start_date"), "2014-11-11 05:00:00")
开发者ID:pombredanne,项目名称:TACTIC,代码行数:29,代码来源:biz_test.py

示例2: get_by_search_type

    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,代码行数:33,代码来源:pipeline.py

示例3: handle_nodes

    def handle_nodes(my, nodes):

        for node in nodes:
            node_name = my.xml.get_node_name(node)
            if node_name == 'search_type':
                my.remove_search_type(node)
            elif node_name == 'sobject':
                my.remove_sobjects(node)
            elif node_name == 'include':
                my.handle_include(node)
            elif node_name == 'python':
                my.handle_python(node)


        # remove plugin contents
        search = Search("config/plugin_content")
        search.add_filter("plugin_code", my.code)
        plugin_contents = search.get_sobjects()
        for plugin_content in plugin_contents:
            plugin_content.delete()



        # deregister the plugin
        plugin = Search.eval("@SOBJECT(config/plugin['code','%s'])" % my.code, single=True)
        if plugin:
            plugin.delete()
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:27,代码来源:plugin.py

示例4: execute

    def execute(my):

        web = WebContainer.get_web()
        if web.get_form_value("update") != "true":
            return

        my.element_name = my.kwargs.get("element_name")

        security_groups = web.get_form_values("security")
        from pyasm.security import AccessRuleBuilder, AccessManager

        rule_group = "side_bar"

        # get all of the groups
        search = Search("sthpw/login_group")
        login_groups = search.get_sobjects()

        for login_group in login_groups:

            access_rules = login_group.get_xml_value("access_rules")

            # add the rule to each group
            builder = AccessRuleBuilder(access_rules)

            code = login_group.get_value("login_group")
            if code in security_groups:
                builder.remove_rule(rule_group, my.element_name)
            else:
                builder.add_rule(rule_group, my.element_name, "deny")

            login_group.set_value("access_rules", builder.to_string())
            login_group.commit()
开发者ID:blezek,项目名称:TACTIC,代码行数:32,代码来源:view_manager_wdg.py

示例5: execute

    def execute(my):
        my.add_description("Set task's context to match process if empty")
        search = Search('sthpw/task')
        search.add_filter('context', None)
        tasks = search.get_sobjects()
        if tasks and len(tasks) > 700:
	    print "More than 700 tasks are found. Exiting as a precaution."
	    sys.exit(0)
        if not tasks: 
            print "All tasks have context attribute filled in. Exiting."
            sys.exit(0)

        ctr = 0
        for task in tasks:
            context = task.get_value('context')
            process = task.get_value('process')
            search_type = task.get_value('search_type')
            # delete dangling task
            if not search_type:
                task.delete()
                continue
            if not context and process:
                task.set_value('context', process)
                task.commit(triggers=False)
                ctr += 1
        print "%s tasks have been processed. Their context are matched with their process." %ctr   
开发者ID:0-T-0,项目名称:TACTIC,代码行数:26,代码来源:mod_task.py

示例6: execute

    def execute(my):

        search = Search(Submission)
        search.set_show_retired(True)
        submissions = search.get_sobjects()

        for submission in submissions:
            snapshot = Snapshot.get_latest_by_sobject(submission, "publish")
            paths = snapshot.get_all_lib_paths()

            bins = submission.get_bins()
            if not bins:
                 print "Bin for submissin [%s] does not exist" % submission.get_id()
                 continue
            bin = bins[0]
            code = bin.get_code()
            type = bin.get_value("type")
            label = bin.get_value("label")

            for path in paths:
                if not os.path.exists(path):
                    print "WARNING: path '%s' does not exist" % path
                    continue

                dirname = os.path.dirname(path)
                basename = os.path.basename(path)
                
                new_dirname = "%s/%s/%s/%s" % (dirname,type,label,code)
                if not os.path.exists(new_dirname):
                    os.makedirs(new_dirname)

                new_path = "%s/%s" % (new_dirname, basename)

                print new_path
                FileUndo.move(path, new_path)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:35,代码来源:fix_submission.py

示例7: get_art_reference

    def get_art_reference(self):

        widget = Widget()
        help = HelpItemWdg('References', 'References tab lets the user organize art references. Each reference can be [related] to one or more assets defined in TACTIC. It can be set up when you [Edit] the reference.')
        self.add(help)
        div = DivWdg(css="filter_box")
        
        widget.add(div)
        columns = ['description','keywords']
        search_filter = SearchFilterWdg("art_ref_search", columns=columns,\
            has_persistence=False)
       
        div.add(search_filter)
           
        select = FilterSelectWdg("art_ref_category", label='Category: ', css='snall')
        select.set_option("setting", "art_reference_category")
        select.add_empty_option('-- Any --')
        
        div.add( select )

        table = TableWdg("prod/art_reference")
        search = Search("prod/art_reference")
       
        search_filter.alter_search(search)
       
        value = select.get_value()
        if value != "":
            search.add_filter("category", value)
        table.set_search(search)
        widget.add(table)
        return widget
开发者ID:mincau,项目名称:TACTIC,代码行数:31,代码来源:preprod_tab_wdg.py

示例8: fix_day

    def fix_day(my, verbose=False):
        search = Search('sthpw/work_hour')
        sobjects = search.get_sobjects()
        if verbose:
            print "Searching %s" % search_type
            print "  ... found %s sobjects" % len(sobjects)

        for i, sobject in enumerate(sobjects):
            # change back to pst for day that has finite hours
            day = sobject.get_value("day")

            try:
                if not day.endswith('00:00:00'):
                    date, hrs = day.split(' ')
                    new_day = '%s 00:00:00'%date
                    print "code: %s [%s]" %(sobject.get_code(), day)
                    date = parser.parse(new_day)
                    date = date + relativedelta(days=1)
                    print "adjusted day ", date
                    sobject.set_value("day", str(date))
                    sobject.commit(triggers=False)
                    my.count += 1

            except Exception, e:
                if verbose:
                    print "ERROR: ", e, " for sobject: ", sobject.get_search_type(), sobject.get_code()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:26,代码来源:fix_workhour_day.py

示例9: get_display

    def get_display(self):
        outer_div = DivWdg()
        outer_div.set_id('add_deliverable_files_to_package')

        order_code = self.package_sobject.get('order_code')
        order_search = Search('twog/order')
        order_search.add_code_filter(order_code)
        order_sobject = order_search.get_sobject()

        deliverable_files = get_deliverable_files_in_order(order_sobject)
        selected_files = get_files_for_package(self.package_sobject.get_code())

        # Only show the selectable files and the submit button if the parent order has any deliverable files
        if deliverable_files:
            deliverable_file_select_wdg = get_files_checkbox_from_file_list(deliverable_files, selected_files)
            outer_div.add(deliverable_file_select_wdg)

            submit_button = SubmitWdg('Submit')
            submit_button.add_behavior(self.get_submit_button_behavior())

            outer_div.add(submit_button)
        else:
            outer_div.add('<div>No deliverable files are available for this Order yet.</div>')

        return outer_div
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:25,代码来源:add_deliverable_files_to_package_wdg.py

示例10: get_display

    def get_display(self):

        web = WebContainer.get_web()
        search_type = web.get_form_value("browser_search_type")
        search_text = web.get_form_value("browser_search_text")

        div = DivWdg()

        if search_type.startswith("prod/shot"):
            filter = self.get_filter(search_text, ['code','description'])
        elif search_type.startswith("prod/art_reference"):
            filter = self.get_filter(search_text, ['category','description'])
        else:
            filter = self.get_filter(search_text, ['name','code','description'])
        if not filter:
            return div

        search = Search(search_type)

        search.add_where(filter)

        div.add_style("width: 300")
        div.add_style("height: 200")
        div.add_style("overflow: auto")
        table = TableWdg(search_type, "list", css="minimal")
        table.set_show_property(False)
        table.set_sobjects(search.get_sobjects())
        div.add(table)

        return div
开发者ID:mincau,项目名称:TACTIC,代码行数:30,代码来源:sobject_browser_wdg.py

示例11: postprocess

    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,代码行数:32,代码来源:drop_element_wdg.py

示例12: init

 def init(self):
     search = Search(Bin)
     
     search.add_column('type')
     search.add_group_by('type')
     self.set_search_for_options(search, 'type','type')
     self.add_empty_option('-- Any --')
开发者ID:mincau,项目名称:TACTIC,代码行数:7,代码来源:submission_wdg.py

示例13: preprocess

    def preprocess(self):

        sobjects = self.sobjects
        if not sobjects:
            return

        # find all of the instances in a shot
        sobject = sobjects[0]
        foreign_key = sobject.get_foreign_key()

        search_type = WebState.get().get_state("planner_search_type")
        search = Search( search_type )

        search.add_column(foreign_key)

        if len(sobjects) == 1:
            search.add_filter(foreign_key, sobject.get_code())
        else:
            search_codes = [x.get_code() for x in sobjects]
            search.add_filters(foreign_key, search_codes)

        search_type = sobject.get_search_type()
        search.add_order_by(foreign_key)
        children = search.get_sobjects()

        # convert to a dictionary
        for child in children:
            code = child.get_value(foreign_key)
            number = self.numbers.get(code)
            if not number:
                number = 0
           
            number += 1
            self.numbers[code] = number
开发者ID:mincau,项目名称:TACTIC,代码行数:34,代码来源:sobject_planner_wdg.py

示例14: execute

    def execute(self):

        left_cb_name , right_cb_name = self.get_checkbox_names()
        
        web = WebContainer.get_web()

        right_search_keys = web.get_form_values(right_cb_name)
        if not right_search_keys:
            return

        right_sobjects = []
        for right_search_key in right_search_keys:
            right_sobject = Search.get_by_search_key(right_search_key)
            right_sobjects.append(right_sobject)

        search_type = self.get_search_type()

        left_search_keys = web.get_form_values(left_cb_name)
        for left_search_key in left_search_keys:

            left_sobject = Search.get_by_search_key( left_search_key )
            for right_sobject in right_sobjects:
                #instance_name = "%s" % right_sobject.get_value("name")

                left_foreign_key = left_sobject.get_foreign_key()
                right_foreign_key = right_sobject.get_foreign_key()

                instance = SObjectFactory.create(search_type)
                instance.set_value(left_foreign_key, left_sobject.get_code() )
                instance.set_value(right_foreign_key, right_sobject.get_code() )

                name = left_sobject.get_code()
                instance.set_value("name", name)
                instance.commit()
开发者ID:mincau,项目名称:TACTIC,代码行数:34,代码来源:sobject_planner_wdg.py

示例15: setUp

    def setUp(my):
        # start batch environment
        Batch()
        from pyasm.web.web_init import WebInit
        WebInit().execute()

        my.sample3d_env = Sample3dEnvironment(project_code='sample3d')
        my.sample3d_env.create()

        my.test_env = UnittestEnvironment()
        my.test_env.create()

    

        # set up the proper project_type, with the use the ProdDirNaming and ProdFileNaming
        search = Search('sthpw/project')
        search.add_filter('code', 'unittest')
        my.sobj = search.get_sobject()

        # store the original setting in your database
        my.original_proj_type_dict = {'dir_naming_cls': my.sobj.get_value('dir_naming_cls'),
                'file_naming_cls': my.sobj.get_value('file_naming_cls') }

        #my.transaction = Transaction.get(create=True)
        if my.sobj:
            my.sobj.set_value('dir_naming_cls', 'pyasm.prod.biz.ProdDirNaming')
            my.sobj.set_value('file_naming_cls', 'pyasm.prod.biz.ProdFileNaming')
            my.sobj.commit()
        else:
            my.sobj = SearchType.create('sthpw/project_type')
            my.sobj.set_value('dir_naming_cls', 'pyasm.prod.biz.ProdDirNaming')
            my.sobj.set_value('file_naming_cls', 'pyasm.prod.biz.ProdFileNaming')
            my.sobj.set_value('code', 'unittest')
            my.sobj.commit()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:34,代码来源:naming_test.py


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