• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python search.SObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: preprocess

    def preprocess(my):
        search_type_list  = SObject.get_values(my.sobjects, 'search_type', unique=True)
        search_id_dict = {}
        my.ref_sobject_cache = {}

        # initialize the search_id_dict
        for type in search_type_list:
            search_id_dict[type] = []
        # cache it first
        for sobject in my.sobjects:
            search_type = sobject.get_value('search_type')
            search_id_list = search_id_dict.get(search_type)
            search_id_list.append(sobject.get_value('search_id'))

        from pyasm.search import SearchException
        for key, value in search_id_dict.items():
            try:
                ref_sobjects = Search.get_by_id(key, value)
                sobj_dict = SObject.get_dict(ref_sobjects)
            except SearchException, e:
                print "WARNING: search_type [%s] with id [%s] does not exist" % (key, value)
                print str(e)
                sobj_dict = {}

            # store a dict of dict with the search_type as key
            my.ref_sobject_cache[key] = sobj_dict
开发者ID:0-T-0,项目名称:TACTIC,代码行数:26,代码来源:prod_wdg.py


示例2: get_display

    def get_display(my):

        top = DivWdg()

        value = my.get_value()
        widget_type = my.get_option("type")
        if widget_type in ['integer', 'float', 'timecode', 'currency']:
            top.add_style("float: right")
            my.justify = "right"

        elif widget_type in ['date','time']:
            name = my.get_name()
            if value and not SObject.is_day_column(name):
                value = SPTDate.convert_to_local(value)
                value = str(value)

        else:
            top.add_style("float: left")
            my.justify = "left"
        top.add_style("padding-right: 3px")

        top.add_style("min-height: 15px")

        format = my.get_option('format')
        value = my.get_format_value( value, format )

        top.add(value)

        return top
开发者ID:jayvdb,项目名称:TACTIC,代码行数:29,代码来源:format_element_wdg.py


示例3: get_display

    def get_display(my):
        
        #defining init is better than get_display() for this kind of SelectWdg
        search = Search( SearchType.SEARCH_TYPE )
        
        if my.mode == None or my.mode == my.ALL_BUT_STHPW:
            # always add the login / login group search types
            filter = search.get_regex_filter("search_type", "login|task|note|timecard|trigger|milestone", "EQ")
            no_sthpw_filter = search.get_regex_filter("search_type", "^(sthpw).*", "NEQ")   
            search.add_where('%s or %s' %(filter, no_sthpw_filter))
        elif my.mode == my.CURRENT_PROJECT:
            project = Project.get()
            project_code = project.get_code()
            #project_type = project.get_project_type().get_type()
            project_type = project.get_value("type")
            search.add_where("\"namespace\" in ('%s','%s') " % (project_type, project_code))

        
        search.add_order_by("search_type")

        search_types = search.get_sobjects()
        values = SObject.get_values(search_types, 'search_type')
        labels = [ x.get_label() for x in search_types ]
        values.append('CustomLayoutWdg')
        labels.append('CustomLayoutWdg')
        my.set_option('values', values)
        my.set_option('labels', labels)
        #my.set_search_for_options(search, "search_type", "get_label()")
        my.add_empty_option(label='-- Select Search Type --')

        return super(SearchTypeSelectWdg, my).get_display()
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:31,代码来源:misc_input_wdg.py


示例4: get_display

    def get_display(my):
        widget = DivWdg(id='link_view_select')
        widget.add_class("link_view_select")
        if my.refresh:
            widget = Widget()
        else:
            my.set_as_panel(widget)
        
        views = []
        if my.search_type:
            from pyasm.search import WidgetDbConfig
            search = Search( WidgetDbConfig.SEARCH_TYPE )
            search.add_filter("search_type", my.search_type)
            search.add_regex_filter("view", "link_search:|saved_search:", op="NEQI")
            search.add_order_by('view')
            widget_dbs = search.get_sobjects()
            views = SObject.get_values(widget_dbs, 'view')
        
        labels = [view for view in views]

        views.insert(0, 'table')
        labels.insert(0, 'table (Default)')
        st_select = SelectWdg('new_link_view', label='View: ')
        st_select.set_option('values', views)
        st_select.set_option('labels', labels)
        widget.add(st_select)
        return widget
开发者ID:blezek,项目名称:TACTIC,代码行数:27,代码来源:view_manager_wdg.py


示例5: preprocess

    def preprocess(my):
       
        my.is_preprocessed = True
        # get all of the instances

        search = Search("prod/shot_instance")

        # if not used in a TableWdg, only get the shot instances for one asset
        if not my.parent_wdg:
            search.add_filter('asset_code', my.get_current_sobject().get_code())

        search.add_order_by("shot_code")
        instances = search.get_sobjects()

        my.asset_instances = instances

        my.instances = {}
        for instance in instances:
            asset_code = instance.get_value("asset_code")
            
            list = my.instances.get(asset_code)
            if not list:
                list = []
                my.instances[asset_code] = list

            list.append(instance)
       
        search = Search("prod/shot")
        search.add_filters( "code", [x.get_value('shot_code') for x in instances] )
        shots = search.get_sobjects()
        my.shots = SObject.get_dict(shots, ["code"])
        my.shots_list = shots
开发者ID:0-T-0,项目名称:TACTIC,代码行数:32,代码来源:layout_summary_wdg.py


示例6: get_mail_users

    def get_mail_users(my, column):
        # mail groups
        recipients = set()

        expr = my.notification.get_value(column, no_exception=True)
        if expr:
            sudo = Sudo()
            # Introduce an environment that can be reflected
            env = {
                'sobject': my.sobject
            }

            #if expr.startswith("@"):
            #    logins = Search.eval(expr, list=True, env_sobjects=env)
            #else:
            parts = expr.split("\n")

            # go through each login and evaluate each
            logins = []
            for part in parts:
                if part.startswith("@") or part.startswith("{"):
                    results = Search.eval(part, list=True, env_sobjects=env)
                    # clear the container after each expression eval
                    ExpressionParser.clear_cache()
                    # these can just be login names, get the actual Logins
                    if results:
                        if isinstance(results[0], basestring):
                            login_sobjs = Search.eval("@SOBJECT(sthpw/login['login','in','%s'])" %'|'.join(results),  list=True)
                        
                            login_list = SObject.get_values(login_sobjs, 'login')
                            
                            for result in results:
                                # the original result could be an email address already
                                if result not in login_list:
                                    logins.append(result)
                                
                            if login_sobjs:
                                logins.extend( login_sobjs )
                        else:
                            logins.extend(results)

                elif part.find("@") != -1:
                    # this is just an email address
                    logins.append( part )
                elif part:
                    # this is a group
                    group = LoginGroup.get_by_code(part)
                    if group:
                        logins.extend( group.get_logins() )

            del sudo
        else:
            notification_id = my.notification.get_id()
            logins = GroupNotification.get_logins_by_id(notification_id)

        for login in logins:
            recipients.add(login) 

        return recipients
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:59,代码来源:email_handler.py


示例7: get_display

    def get_display(my):
        widget = Widget()
        span = SpanWdg('[ projects ]', css='hand')
        span.add_style('color','white')
        span.add_event('onclick',"spt.show_block('%s')" %my.WDG_ID)
        widget.add(span)
        
        # add the popup
        div = DivWdg(id=my.WDG_ID, css='popup_wdg')
        widget.add(div)
        div.add_style('width', '80px')
        div.add_style('display', 'none')
        title_div = DivWdg()
        div.add(title_div)
        title = FloatDivWdg(' ', width='60px')
        title.add_style('margin-right','2px')
        title_div.add_style('padding-bottom', '4px')
        title_div.add(title)
        title_div.add(CloseWdg(my.get_off_script(), is_absolute=False))


        div.add(HtmlElement.br())
        
        search = Search(Project)
        search.add_where("\"code\" not in ('sthpw','admin')")
        search.add_column('code')
        projects = search.get_sobjects()
        values = SObject.get_values(projects, 'code')

        web = WebContainer.get_web()
        root = web.get_site_root()
        
        
        security = Environment.get_security()
        for value in values:
            if not security.check_access("project", value, "view"):
                continue
            script = "location.href='/%s/%s'"%(root, value)
            sub_div = DivWdg(HtmlElement.b(value), css='selection_item') 
            sub_div.add_event('onclick', script)
            div.add(sub_div)
        
        div.add(HtmlElement.hr())
        if security.check_access("project", 'default', "view"):
            script = "location.href='/%s'" % root
            sub_div = DivWdg('home', css='selection_item') 
            sub_div.add_event('onclick', script)
            div.add(sub_div)

        if security.check_access("project", "admin", "view"):
            script = "location.href='/%s/admin/'" %root
            sub_div = DivWdg('admin', css='selection_item') 
            sub_div.add_event('onclick', script)
            div.add(sub_div)

       

        return widget
开发者ID:0-T-0,项目名称:TACTIC,代码行数:58,代码来源:header_wdg.py


示例8: build_cache_by_column

    def build_cache_by_column(self, column):
        # do not build if it already exists
        if self.caches.has_key(column):
            return

        # build a search_key cache
        column_cache = SObject.get_dict(self.sobjects, key_cols=[column])
        self.caches[column] = column_cache
        return column_cache
开发者ID:mincau,项目名称:TACTIC,代码行数:9,代码来源:cache.py


示例9: get_display

    def get_display(my):
        sobject = my.get_current_sobject()

        column =  my.kwargs.get('column')
        if column:
            name = column
        else:
            name = my.get_name()
        
        value = my.get_value(name=name)

        if sobject:
            data_type = SearchType.get_column_type(sobject.get_search_type(), name)
        else:
            data_type = 'text'

        if type(value) in types.StringTypes:
            wiki = WikiUtil()
            value = wiki.convert(value) 
        if name == 'id' and value == -1:
            value = ''

        elif data_type == "timestamp" or name == "timestamp":
	    if value == 'now':
                value = ''
            elif value:
                # This date is assumed to be GMT
                date = parser.parse(value)
                # convert to local
                if not SObject.is_day_column(name):
                    date = SPTDate.convert_to_local(date)
		try:
		   encoding = locale.getlocale()[1]		
		   value = date.strftime("%b %d, %Y - %H:%M").decode(encoding)
		except:
		   value = date.strftime("%b %d, %Y - %H:%M")

            else:
                value = ''
        else:
            if isinstance(value, Widget):
                return value
            elif not isinstance(value, basestring):
                try:
                    value + 1
                except TypeError:
                    value = str(value)
                else:
                    value_wdg = DivWdg()
                    value_wdg.add_style("float: right")
                    value_wdg.add_style("padding-right: 3px")
                    value_wdg.add( str(value) )
                    return value_wdg

        return value
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:55,代码来源:base_table_element_wdg.py


示例10: get_registered_hours

 def get_registered_hours(search_key, week, weekday, year, desc=None, login=None, project=None):
     ''' get the total registered hours for the week. ADD YEAR!!!'''
     timecards = Timecard.get(search_key, week, year, desc, login, project)
     
     hours = SObject.get_values(timecards, weekday, unique=False)
     
     reg_hours = 0.0
     for hour in hours:
         if hour:
             reg_hours += float(hour)
     
     return reg_hours
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:12,代码来源:task.py


示例11: get_tasks

    def get_tasks(self, sobject):

        search_type = SearchType.get("prod/shot").get_full_key()

        # get all of the shots in the episode
        shots = sobject.get_all_children("prod/shot")
        ids = SObject.get_values(shots, "id")

        search = Search("sthpw/task")
        search.add_filter("search_type", search_type)
        search.add_filters("search_id", ids)
        return search.get_sobjects()
开发者ID:mincau,项目名称:TACTIC,代码行数:12,代码来源:statistics_wdg.py


示例12: preprocess

    def preprocess(my):
        
        # protect against the case where there is a single sobject that
        # is an insert (often seen in "insert")
        if my.is_preprocessed == True:
            return

        skip = False
        if len(my.sobjects) == 1:
            if not my.sobjects[0].has_value("search_type"):
                skip = True

        if not skip:
            search_types = SObject.get_values(my.sobjects, 'search_type', unique=True)

            try:
                search_codes = SObject.get_values(my.sobjects, 'search_code', unique=True)
                search_ids = None
            except Exception, e:
                print "WARNING: ", e
                search_ids = SObject.get_values(my.sobjects, 'search_id', unique=True)
                search_codes = None
开发者ID:0-T-0,项目名称:TACTIC,代码行数:22,代码来源:group_element_wdg.py


示例13: get_info

 def get_info(self):
     # check if the sobj type is the same
     search_types = SObject.get_values(self.sobjs, 'search_type', unique=True)
     search_ids = SObject.get_values(self.sobjs, 'search_id', unique=False)
   
     infos = []
     # this doesn't really work if the same asset is submitted multiple times
     if len(search_types) == 1 and len(search_ids) == len(self.sobjs):
         assets = []
         if search_types[0]:
             assets = Search.get_by_id(search_types[0], search_ids)
         
         asset_dict = SObject.get_dict(assets)
         for id in search_ids:
             asset = asset_dict.get(id)
             aux_dict = {}
             aux_dict['info'] = SubmissionInfo._get_target_sobject_data(asset)
             aux_dict['search_key'] = '%s:%s' %(search_types[0], id)
             infos.append(aux_dict)
         
     else:
         # TODO: this is a bit database intensive, mixed search_types not
         # recommended
         search_types = SObject.get_values(self.sobjs, 'search_type',\
             unique=False)
         for idx in xrange(0, len(search_types)):
             search_type = search_types[idx]
                 
             aux_dict = {}
             aux_dict['info'] = ''
             aux_dict['search_key'] = ''
             if search_type:
                 asset = Search.get_by_id(search_type, search_ids[idx])
                 aux_dict['info'] = SubmissionInfo._get_target_sobject_data(asset)
                 aux_dict['search_key'] = '%s:%s' %(search_types[idx], search_ids[idx])
             infos.append(aux_dict)
     return infos
开发者ID:mincau,项目名称:TACTIC,代码行数:37,代码来源:submission_wdg.py


示例14: get_display

    def get_display(my):

        top = DivWdg()

        value = my.get_value()
        widget_type = my.get_option("type")
        
        if widget_type in ['integer', 'float', 'timecode', 'currency']:
            top.add_style("float: right")
            my.justify = "right"

        elif widget_type in ['date','time']:
            name = my.get_name()
            if value and not SObject.is_day_column(name):               
                value = my.get_timezone_value(value)
         

                value = str(value)

        else:
            top.add_style("float: left")
            my.justify = "left"
        top.add_style("padding-right: 3px")

        top.add_style("min-height: 15px")

        format = my.get_option('format')
        value = my.get_format_value( value, format )
        top.add(value)


        sobject = my.get_current_sobject()
        if sobject:

            column =  my.kwargs.get('column')
            if column:
                name = column
            else:
                name = my.get_name()

            top.add_update( {
                'search_key': sobject.get_search_key(),
                'column': name,
                'format': format

            } )

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


示例15: update_process_table

    def update_process_table(my):
        ''' make sure to update process table'''
        process_names = my.get_process_names()
        pipeline_code = my.get_code()

        search = Search("config/process")
        search.add_filter("pipeline_code", pipeline_code)
        process_sobjs = search.get_sobjects()
        existing_names = SObject.get_values(process_sobjs, 'process')

        count = 0
        for process_name in process_names:

            exists = False
            for process_sobj in process_sobjs:
                # if it already exist, then update
                if process_sobj.get_value("process") == process_name:
                    exists = True
                    break
            if not exists:
                process_sobj = SearchType.create("config/process")
                process_sobj.set_value("pipeline_code", pipeline_code)
                process_sobj.set_value("process", process_name)
            
            attrs = my.get_process_attrs(process_name)
            color = attrs.get('color')
            if color:
                process_sobj.set_value("color", color)

            process_sobj.set_value("sort_order", count)
            process_sobj.commit()
            count += 1


        # delete obsolete
        obsolete = set(existing_names) - set(process_names)
        if obsolete:
            for obsolete_name in obsolete:
                for process_sobj in process_sobjs:
                    # delete it
                    if process_sobj.get_value("process") == obsolete_name:
                        process_sobj.delete()
                        break
开发者ID:funic,项目名称:TACTIC,代码行数:43,代码来源:pipeline.py


示例16: postprocess

    def postprocess(my):
        super(FlashAssetPublishCmd, my).postprocess()

        # parse the introspect file
        code = my.sobject.get_code()
       
        upload_dir = my.get_upload_dir()
        introspect_path = "%s/%s.xml" % (upload_dir, code)

        xml = Xml()
        xml.read_file(introspect_path)

        flash_layer_names = xml.get_values("introspect/layers/layer/@name")
        if not flash_layer_names:
            return

        # extract the layers from the flash layer_names
        layer_names = []
        for flash_layer_name in flash_layer_names:
            if flash_layer_name.find(":") == -1:
                continue
            layer_name, instance_name = flash_layer_name.split(":")

            # make sure it is unique
            if layer_name not in layer_names:
                layer_names.append(layer_name)

        base_key = my.sobject.get_search_type_obj().get_base_key()

        # TODO: make the flash shot tab run FlashShotPublishCmd instead
        # and move this postprocess there
        # this is not meant for flash/asset, but for flash/shot
        if base_key == 'flash/asset' or not layer_names:
            return

        # get all of the layers in this shot and compare to the session
        existing_layers = my.sobject.get_all_children("prod/layer")
        existing_layer_names = SObject.get_values(existing_layers,"name")
        for layer_name in layer_names:
            if layer_name not in existing_layer_names:
                print "creating ", layer_name
                Layer.create(layer_name, code)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:42,代码来源:flash_publish_cmd.py


示例17: _get_bins

    def _get_bins(self):
        
        search = Search(Bin)

        # get all the types in the Bin table
        type_search = Search(Bin)
        type_search.add_column('type')
        type_search.add_group_by('type')
        types = SObject.get_values(type_search.get_sobjects(), 'type')

        select = SelectWdg('display_limit')
        select.set_option('persist', 'true')
        display_limit = select.get_value()
        if display_limit:
            self.display_limit = display_limit

        # by default, get 10 for each type
        joined_statements = []
        for type in types:
            # TODO: fix this sql to run through search
            select = Search('prod/bin')
            select.add_filter("type", type)
            select.set_show_retired(False)
            select.add_order_by("code")
            select.add_limit(self.display_limit)
            statement = select.get_statement()
            joined_statements.append(statement)

            #joined_statements.append("select * from \"bin\" where \"type\" ='%s' and (\"s_status\" != 'retired' or \"s_status\" is NULL)" \
            #    " order by \"code\" desc limit %s" % (type, self.display_limit))

        if len(joined_statements) > 1:
            joined_statements = ["(%s)"%x for x in joined_statements]
            statement = ' union all '.join(joined_statements)
        elif len(joined_statements) == 1:
            statement = joined_statements[0]
        else:
            # no bins created yet
            return []
        #print "statement: ", statement
    
        return Bin.get_by_statement(statement)
开发者ID:mincau,项目名称:TACTIC,代码行数:42,代码来源:submission_wdg.py


示例18: get_text_value

    def get_text_value(my):

        value = my.get_value()
        widget_type = my.get_option("type")
        
        if widget_type in ['date','time']:
            name = my.get_name()
            if not SObject.is_day_column(name):
                value = my.get_timezone_value(value)
                value = str(value)
 
        format = my.get_option('format')
        
        if format == 'Checkbox':
            value = str(value)
        else:
            value = my.get_format_value( value, format )

       
        return value
开发者ID:0-T-0,项目名称:TACTIC,代码行数:20,代码来源:format_element_wdg.py


示例19: get_behavior

    def get_behavior(cls, sobject):
        '''it takes sobject as an argument and turn it into a dictionary to pass to 
            NotificationTestCmd'''
        pal = WebContainer.get_web().get_palette()
        bg_color = pal.color('background')
        sobj_dict = SObject.get_sobject_dict(sobject)
        sobj_json = jsondumps(sobj_dict)
        bvr = {'type': 'click_up',
                 'cbjs_action': '''
                   var server = TacticServerStub.get();
                   var rtn = {};
                   var msg = '';

                   try
                   { 
                      spt.app_busy.show( 'Email Test', 'Waiting for email server response...' );
                      rtn = server.execute_cmd('tactic.command.NotificationTestCmd', args={'sobject_dict': %s});
                      msg = rtn.description;
                      msg += '\\nYou can also review the notification in the Notification Log.'
                   }
                   catch(e) {
                       msg = 'Error found in this notification:\\n\\n' + spt.exception.handler(e);
                   }
                   //console.log(msg)
                   spt.app_busy.hide();
                   var popup_id = 'Notification test result';

                   var class_name = 'tactic.ui.panel.CustomLayoutWdg';

                   msg= msg.replace(/\\n/g, '<br/>');

                   var options = { 'html': '<div><div style="background:%s; padding: 5px">' + msg + '</div></div>'};
                   var kwargs = {'width':'600px'};
                   spt.panel.load_popup(popup_id, class_name, options, kwargs);
                   
                  ''' %(sobj_json, bg_color)}
        return bvr
开发者ID:funic,项目名称:TACTIC,代码行数:37,代码来源:table_element_wdg.py


示例20: get_tasks

    def get_tasks(my, sobjects=[]):


        # get all of the relevant tasks to the user
        task_search = Search("sthpw/task")
        task_search.add_column("search_id", distinct=True)


        if sobjects:
            task_search.add_filter("search_type", sobjects[0].get_search_type() )
            sobject_ids = SObject.get_values(sobjects, "id", unique=True)
            task_search.add_filters("search_id", sobject_ids)


        # only look at this project
        search_type = SearchType.get(my.search_type).get_full_key()
        task_search.add_filter("search_type", search_type)


        my.process_filter.alter_search(task_search)
        if isinstance(my.user_filter, UserFilterWdg):
            my.user_filter.alter_search(task_search)
        else:
            user = Environment.get_user_name()
            task_search.add_filter('assigned', user)
        
        status_filters = my.task_status_filter.get_values()
        
        if not status_filters:
            return []

        task_search.add_filters("status", status_filters)

        tasks = task_search.get_sobjects()
        
        return tasks
开发者ID:0-T-0,项目名称:TACTIC,代码行数:36,代码来源:approval_manager_wdg.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python search.SObjectFactory类代码示例发布时间:2022-05-25
下一篇:
Python search.DbContainer类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap