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


Python search.SObject类代码示例

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


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


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