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


Python SearchType.create方法代码示例

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


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

示例1: create

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

        project = Project.get_by_code(self.project_code)
        if project:

            self.delete()

        print "Setting up a basic Sample3d project"

        # create the project
        create_cmd = CreateProjectCmd(project_code=self.project_code, project_title="Sample 3D") #, project_type="unittest")
        create_cmd.execute()

        # install the unittest plugin
        installer = PluginInstaller(relative_dir="TACTIC/internal/sample3d", verbose=False)
        installer.execute()

        # add 30 shots
        for x in xrange(30):
            shot = SearchType.create("prod/shot")
            shot.set_value('name','shot%s'%x)
            shot.set_value('sequence_code','SEQ_01')
            shot.commit(triggers=False)

        if not Search.eval("@SOBJECT(prod/sequence['code','SEQ_01'])"):
            seq = SearchType.create("prod/sequence")
            seq.set_value('code','SEQ_01')
            seq.commit(triggers=False)
开发者ID:mincau,项目名称:TACTIC,代码行数:30,代码来源:environment.py

示例2: _test_base_dir_alias

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

        Config.set_value("checkin", "asset_base_dir", {
            'default': '/tmp/tactic/default',
            'alias': '/tmp/tactic/alias',
            'alias2': '/tmp/tactic/alias2',
        });
        asset_dict = Environment.get_asset_dirs()
        default_dir = asset_dict.get("default")
        my.assertEquals( "/tmp/tactic/default", default_dir)

        aliases = asset_dict.keys()
        # "plugins" is assumed in some branch 
        if 'plugins' in aliases:
            my.assertEquals( 4, len(aliases))
        else:
            my.assertEquals( 3, len(aliases))
        my.assertNotEquals( None, "alias" in aliases )

        # create a naming
        naming = SearchType.create("config/naming")
        naming.set_value("search_type", "unittest/person")
        naming.set_value("context", "alias")
        naming.set_value("dir_naming", "alias")
        naming.set_value("file_naming", "text.txt")
        naming.set_value("base_dir_alias", "alias")
        naming.commit()

        # create 2nd naming where 
        naming = SearchType.create("config/naming")
        naming.set_value("search_type", "unittest/person")
        naming.set_value("context", "alias2")
        naming.set_value("dir_naming", "alias2")
        naming.set_value("base_dir_alias", "alias2")
        naming.set_value("file_naming", "text.txt")
        naming.set_value("checkin_type", "auto")
        naming.commit()

        my.clear_naming()

        # create a new test.txt file
        for context in ['alias', 'alias2']:
            file_path = "./test.txt"
            file = open(file_path, 'w')
            file.write("whatever")
            file.close()

            checkin = FileCheckin(my.person, file_path, context=context)
            checkin.execute()
            snapshot = checkin.get_snapshot()

            lib_dir = snapshot.get_lib_dir()
            expected = "/tmp/tactic/%s/%s" % (context, context)
            my.assertEquals(expected, lib_dir)

            path = "%s/text.txt" % (lib_dir)
            exists = os.path.exists(path)
            my.assertEquals(True, exists)
开发者ID:hellios78,项目名称:TACTIC,代码行数:60,代码来源:checkin_test.py

示例3: get_message

# 需要导入模块: from pyasm.search import SearchType [as 别名]
# 或者: from pyasm.search.SearchType import create [as 别名]
    def get_message(my):
        search_type_obj = my.sobject.get_search_type_obj()
        title = search_type_obj.get_title()
        subject = my.get_subject()
        notification_message = my.notification.get_value("message")
        if notification_message:
            # parse it through the expression
            sudo = Sudo()
            parser = ExpressionParser()
            snapshot = my.input.get('snapshot')
            env_sobjects = {}

            # turn prev_data and update_data from input into sobjects
            prev_data = SearchType.create("sthpw/virtual")
            id_col = prev_data.get_id_col()

            if id_col:
                del prev_data.data[id_col]

            prev_dict = my.input.get("prev_data")
            if prev_dict:
                for name, value in prev_dict.items():
                    if value != None:
                        prev_data.set_value(name, value)


            update_data = SearchType.create("sthpw/virtual")
            id_col = update_data.get_id_col()

            if id_col:
                del update_data.data[id_col]

            update_dict = my.input.get("update_data")
            if update_dict:
                for name, value in update_dict.items():
                    if value != None:
                        update_data.set_value(name, value)



            if snapshot:

                env_sobjects = {
                'snapshot': snapshot
            }


            env_sobjects['prev_data'] = prev_data
            env_sobjects['update_data'] = update_data

            notification_message  = parser.eval(notification_message, my.sobject, env_sobjects=env_sobjects, mode='string')
            del sudo
            return notification_message

        message = "%s %s" % (title, my.sobject.get_name())
        message = '%s\n\nReport from transaction:\n%s\n' % (message, subject)
        return message
开发者ID:0-T-0,项目名称:TACTIC,代码行数:59,代码来源:email_handler.py

示例4: execute

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

        import types

        transaction_xml = my.kwargs.get("transaction_xml")
        file_mode = my.kwargs.get("file_mode")
        if not file_mode:
            file_mode = 'delayed'

        # if the first argument is a dictionary, then the whole
        # transaction sobject was passed through
        # NOTE: this is now the default
        if type(transaction_xml) == types.DictType:
            transaction_dict = transaction_xml
            transaction_xml = transaction_dict.get("transaction")
            timestamp = transaction_dict.get("timestamp")
            login = transaction_dict.get("login")

            # recreate the transaction
            transaction = SearchType.create("sthpw/transaction_log")
            for name, value in transaction_dict.items():
                if name.startswith("__"):
                    continue
                if name == 'id':
                    continue
                if value == None:
                    continue
                transaction.set_value(name, value)

        elif isinstance(transaction_xml, SObject):
            transaction = transaction_xml

        else:
            # Create a fake transaction.
            # This is only used for test purposes
            transaction = SearchType.create("sthpw/transaction_log")
            if transaction_xml:
                transaction.set_value("transaction", transaction_xml)
            else:
                print "WARNING: transaction xml is empty"
            transaction.set_value("login", "admin")

            # commit the new transaction.  This is the only case where
            # a transaction will not have a code, so it has to be committed.
            # The other case do not need to be committed because they will
            # already have codes and the transaction is committed in 
            # RedoCmd
            # 
            try:
                transaction.commit()
            except Exception, e:
                print "Failed to commit transaction [%s]: It may already exist. Skipping." % transaction.get_code()
                print str(e)
                return
开发者ID:0-T-0,项目名称:TACTIC,代码行数:56,代码来源:run_transaction_cmd.py

示例5: get_pipeline

# 需要导入模块: from pyasm.search import SearchType [as 别名]
# 或者: from pyasm.search.SearchType import create [as 别名]
    def get_pipeline(my, pipeline_xml, add_tasks=False):

        pipeline = SearchType.create("sthpw/pipeline")
        pipeline.set_pipeline(pipeline_xml)
        pipeline_id = random.randint(0, 10000000)
        #pipeline.set_value("code", "test%s" % pipeline_id)
        #pipeline.set_id(pipeline_id)
        #pipeline.set_value("id", pipeline_id)
        pipeline.set_value("pipeline", pipeline_xml)
        pipeline.commit()

        process_names = pipeline.get_process_names()

        # delete the processes
        search = Search("config/process")
        search.add_filters("process", process_names)
        processes = search.get_sobjects()
        for process in processes:
            process.delete()

        # create new processes
        processes_dict = {}
        for process_name in process_names:

            # define the process nodes
            process = SearchType.create("config/process")
            process.set_value("process", process_name)
            process.set_value("pipeline_code", pipeline.get_code())
            process.set_json_value("workflow", {
                'on_complete': '''
                sobject.set_value('%s', "complete")
                ''' % process_name,
                'on_approve': '''
                sobject.set_value('%s', "approve")
                ''' % process_name,
 
            } )
            process.commit()

            processes_dict[process_name] = process


            # Note: we don't have an sobject yet
            if add_tasks:
                task = SaerchType.create("sthpw/task")
                task.set_parent(sobject)
                task.set_value("process", process_name)
                task.commit()


        return pipeline, processes_dict
开发者ID:nuxping,项目名称:TACTIC,代码行数:53,代码来源:workflow_test.py

示例6: _test_sobject_hierarchy

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

        # FIXME: this functionality has been disabled until further notice
        return

        snapshot_type = SearchType.create("sthpw/snapshot_type")
        snapshot_type.set_value("code", "maya_model")
        snapshot_type.commit()

        snapshot_type = SearchType.create("prod/snapshot_type")
        snapshot_type.set_value("code", "maya_model")
        snapshot_type.commit()

        snapshot_type = SnapshotType.get_by_code("maya_model")
开发者ID:funic,项目名称:TACTIC,代码行数:16,代码来源:biz_test.py

示例7: _test_time

# 需要导入模块: from pyasm.search import SearchType [as 别名]
# 或者: from pyasm.search.SearchType import create [as 别名]
    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')


        # test NOW() auto conversion
        sobj = SearchType.create('sthpw/note')
        sobj.set_value('process','TEST')
        sobj.set_value('note','123')
        my.assertEquals(sobj.get_value('timestamp'), "")
        sobj.commit()

        # this is local commited time converted back to GMT
        committed_time = sobj.get_value('timestamp')
        
        from dateutil import parser
        committed_time = parser.parse(committed_time)

        from pyasm.common import SPTDate
        now = SPTDate.now()
        diff = now - committed_time
        # should be roughly the same minute, not hours apart
        my.assertEquals(diff.seconds < 60, True)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:50,代码来源:biz_test.py

示例8: _test_trigger

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

        # create a dummy sobject
        sobject = SearchType.create("unittest/person")

        pipeline_xml = '''
        <pipeline>
          <process type="action" name="a"/>
        </pipeline>
        '''
        pipeline, processes = my.get_pipeline(pipeline_xml)

        process = processes.get("a")
        process.set_value("workflow", "")
        process.commit()


        folder = Common.generate_alphanum_key()

        Trigger.clear_db_cache()
        event = "process|action"
        trigger = SearchType.create("config/trigger")
        trigger.set_value("event", event)
        trigger.set_value("process", process.get_code())
        trigger.set_value("mode", "same process,same transaction")
        trigger.set_value("script_path", "%s/process_trigger" % folder)
        trigger.commit()

        script = SearchType.create("config/custom_script")
        script.set_value("folder", folder)
        script.set_value("title", "process_trigger")
        script.set_value("script", '''
        print "---"
        for key, value in input.items():
            print key, value
        print "---"
        print "process: ", input.get("process")
        ''')
        script.commit()
 
        # Run the pipeline
        process = "a"
        output = {
            "pipeline": pipeline,
            "sobject": sobject,
            "process": process
        }
        Trigger.call(my, "process|pending", output)
开发者ID:jayvdb,项目名称:TACTIC,代码行数:50,代码来源:workflow_test.py

示例9: _test_js

# 需要导入模块: from pyasm.search import SearchType [as 别名]
# 或者: from pyasm.search.SearchType import create [as 别名]
    def _test_js(my):
        # create a dummy sobject
        sobject = SearchType.create("sthpw/virtual")
        sobject.set_value("code", "test")

        # simple condition
        pipeline_xml = '''
        <pipeline>
          <process type="action" name="a"/>
        </pipeline>
        '''
        pipeline, processes = my.get_pipeline(pipeline_xml)

        process = processes.get("a")
        process.set_json_value("workflow", {
            'cbjs_action': '''
            console.log("This is javascript");
            console.log(input);
            return false
            '''
        } )
        process.commit()


        process = "a"
        output = {
            "pipeline": pipeline,
            "sobject": sobject,
            "process": process,
            "status": "pending"
        }

        import time
        start = time.time()
        Trigger.call(my, "process|pending", output)
开发者ID:jayvdb,项目名称:TACTIC,代码行数:37,代码来源:workflow_test.py

示例10: postprocess

# 需要导入模块: from pyasm.search import SearchType [as 别名]
# 或者: from pyasm.search.SearchType import create [as 别名]
    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,代码行数:34,代码来源:drop_element_wdg.py

示例11: handle_config2

# 需要导入模块: from pyasm.search import SearchType [as 别名]
# 或者: from pyasm.search.SearchType import create [as 别名]
    def handle_config2(my):
        """for db column search config stuff, not used yet"""
        web = WebContainer.get_web()

        search_type = "SearchTypeSchema"
        view = "definition"

        config_search_type = "config/widget_config"

        search = Search(config_search_type)
        search.add_filter("search_type", search_type)
        search.add_filter("view", view)
        config = search.get_sobject()
        if not config:
            config = SearchType.create(config_search_type)
            config.set_value("search_type", search_type)
            config.set_value("view", view)
            xml = config.get_xml_value("config", "config")
            root = xml.get_root_node()
            # reinitialize
            config._init()

            # build a new config
            view_node = xml.create_element(view)
            root.appendChild(view_node)

        config_mode = web.get_form_value("config_mode")
        if config_mode == "advanced":
            config_string = web.get_form_value("config_xml")
        else:
            config_data_type = web.get_form_value("config_data_type")
            if config_data_type == "Other...":
                config_data_type = web.get_form_value("config_data_type_custom")
            config_nullable = web.get_form_value("config_nullable")

            # TAKEN FROM API: should be centralized or something
            from tactic.ui.panel import SideBarBookmarkMenuWdg

            config_view = SideBarBookmarkMenuWdg.get_config(search_type, view)
            node = config_view.get_element_node(my.element_name)
            if node:
                config_xml = config_view.get_xml()

                node = config_view.get_element_node(my.element_name)
                Xml.set_attribute(node, "data_type", config_data_type)
                Xml.set_attribute(node, "nullable", config_nullable)
                Xml.set_attribute(node, "new", "True")

                config_string = config_xml.to_string(node)
            else:
                config_string = """
                <element name="%s" data_type="%s" nullable="%s" new="True"/>
                """ % (
                    my.element_name,
                    config_data_type,
                    config_nullable,
                )

        config.append_xml_element(my.element_name, config_string)
        config.commit_config()
开发者ID:pombredanne,项目名称:TACTIC,代码行数:62,代码来源:search_type_manager_wdg.py

示例12: create

# 需要导入模块: from pyasm.search import SearchType [as 别名]
# 或者: from pyasm.search.SearchType import create [as 别名]
    def create(cls, sobject, process, description="", assigned="", supervisor="",\
            status=None, depend_id=None, project_code=None, pipeline_code='', \
            start_date=None, end_date=None, context='', bid_duration=8):


        task = SearchType.create( cls.SEARCH_TYPE )
        task.set_parent(sobject)

        task.set_value("process", process )
        if description:
            task.set_value("description", description )
        if assigned != None:
            task.set_value("assigned", assigned)

        if supervisor != None:
            task.set_value("supervisor", supervisor)

        if not project_code:
            project_code = sobject.get_project_code()
        task.set_value("project_code", project_code )
        task.set_value("pipeline_code", pipeline_code) 

        if not status:
            pipeline = task.get_pipeline()
            process_names = pipeline.get_process_names()
            if process_names:
                status = process_names[0]

        if status:
            task.set_value("status", status)

        if bid_duration:
            task.set_value("bid_duration", bid_duration)


        if start_date:
            task.set_value("bid_start_date", start_date)
        if end_date:
            task.set_value("bid_end_date", end_date)
        # auto map context as process as the default
        #if not context:
        #    context = process
        # let get_defaults() set the context properly instead of auto-map
        if context:
            task.set_value("context", context)

        # DEPRECATED
        if depend_id:
            task.set_value("depend_id", depend_id)

        # created by 
        if task.has_value('login'):
            user = Environment.get_user_name()
            task.set_value('login', user)

        task.commit(triggers=True)
        # log the status creation event
        StatusLog.create(task, status)

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

示例13: _test_time

# 需要导入模块: from pyasm.search import SearchType [as 别名]
# 或者: from pyasm.search.SearchType import create [as 别名]
    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,代码行数:31,代码来源:biz_test.py

示例14: execute

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

        # save prefix
        local_prefix = self.get_value("local_prefix")
        self.server_prefix = Config.get_value("install", "server")

        if not local_prefix and not self.server_prefix:
            raise TacticException("Cannot have empty local server prefix")

        if local_prefix and local_prefix != self.server_prefix:
            Config.set_value("install", "server", local_prefix)

            Config.save_config()

        self.project_code = self.get_value("project")
        if not self.project_code:
            self.project_code = Project.get_project_code()


        # create a share
        share = SearchType.create("sthpw/sync_server")
        self.handle_info(share)
        self.handle_sync_mode(share)

        share.commit()
开发者ID:mincau,项目名称:TACTIC,代码行数:27,代码来源:sync_settings_wdg.py

示例15: get_display

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

        top = DivWdg()
        my.set_as_panel(top)

        sobject = SearchType.create("sthpw/virtual")
        sobject.set_value("mon", "3")
        sobject.set_value("tue", "2")
        sobject.set_value("wed", "5")

        config = '''
        <week>
            <element name="week"/>
            <element name="parent"/>
            <element name="category"/>
            <element name="description"/>
            <element name="mon"/>
            <element name="tue"/>
            <element name="wed"/>
            <element name="thu"/>
            <element name="fri"/>
            <element name="total"/>
        </week>
        '''

        table = TableLayoutWdg(search_type='sthpw/virtual', view='week')
        top.add(table)

        return top
开发者ID:0-T-0,项目名称:TACTIC,代码行数:31,代码来源:work_hour_wdg.py


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