Example #1
0
    def get_path_from_sobject(my, sobject):

        icon_path = None
        path = None

        search_type = sobject.get_search_type()
        search_code = sobject.get_value("code", no_exception=True)
        if not search_code:
            search_code = sobject.get_id()

        # FIXME: make this faster
        snapshot = Snapshot.get_snapshot(search_type, search_code, context='icon')
        if not snapshot:
            snapshot = Snapshot.get_snapshot(search_type, search_code, context='publish')
        if not snapshot:
            snapshot = Snapshot.get_snapshot(search_type, search_code, process='publish')
        if not snapshot:
            snapshot = Snapshot.get_snapshot(search_type, search_code)


        if snapshot:
            file_type = "web"
            icon_path = snapshot.get_web_path_by_type(file_type)

            file_type = "main"
            path = snapshot.get_web_path_by_type(file_type)

        if icon_path:
            path = icon_path
        elif path:
            path = my.find_icon_link(path)

 
        return path
    def get_path_from_sobject(my, sobject):

        icon_path = None
        path = None

        base_search_type = sobject.get_base_search_type()
        if base_search_type == "sthpw/snapshot":
            #sobject = sobject.get_parent()
            snapshot = sobject

        else:
            search_type = sobject.get_search_type()
            search_code = sobject.get_value("code", no_exception=True)
            if not search_code:
                search_code = sobject.get_id()


            # FIXME: make this faster

            snapshot = Snapshot.get_snapshot(search_type, search_code, process=['icon','publish',''])

        if snapshot:
            file_type = "web"
            icon_path = snapshot.get_web_path_by_type(file_type)

            file_type = "main"
            path = snapshot.get_web_path_by_type(file_type)

        if icon_path:
            path = icon_path
        elif path:
            path = my.find_icon_link(path)

 
        return path
Example #3
0
    def get_path_from_sobject(my, sobject):

        icon_path = None
        path = None

        base_search_type = sobject.get_base_search_type()
        if base_search_type == "sthpw/snapshot":
            #sobject = sobject.get_parent()
            snapshot = sobject

        else:
            search_type = sobject.get_search_type()
            search_code = sobject.get_value("code", no_exception=True)
            if not search_code:
                search_code = sobject.get_id()


            # FIXME: make this faster

            snapshot = Snapshot.get_snapshot(search_type, search_code, process=['icon','publish',''])

        if snapshot:
            file_type = "web"
            icon_path = snapshot.get_web_path_by_type(file_type)

            file_type = "main"
            path = snapshot.get_web_path_by_type(file_type)

        if icon_path:
            path = icon_path
        elif path:
            path = my.find_icon_link(path)

 
        return path
Example #4
0
    def get_bottom(my):
        if my.get_option('mode') =='input':
            return 
        web = WebContainer.get_web()
        if web.get_selected_app() not in ['XSI','Maya']:
            return
        div = DivWdg( css='spt_outdated_ref')
       

        refs = my.session.get_data().get_nodes("session/node/ref")
        snap_codes = []
        snap_contexts = []
        sobjects = []
        session_data_dict = {}
        asset_codes = []
        current_snapshots = []
        node_names = []
        session_versions = []
        for ref in refs:
            snap_code = Xml.get_attribute(ref, "asset_snapshot_code")
            node_name = Xml.get_attribute(ref, "name")
            version = Xml.get_attribute(ref, "asset_snapshot_version")
            asset_code = Xml.get_attribute(ref, "asset_code")
            if snap_code in snap_codes:
                continue
            snap_codes.append(snap_code)
            snap_contexts.append(Xml.get_attribute(ref, "asset_snapshot_context"))
            asset_codes.append(asset_code)
            session_data_dict[snap_code] = version, node_name  
        
        
        # must search one by one
        warnings=[]
        for idx, snap_code in enumerate(snap_codes):
            snapshot = Snapshot.get_by_code(snap_code)
            if not snapshot:
                continue
            search_type = snapshot.get_value('search_type')
            search_id = snapshot.get_value('search_id')
            current_snapshot = Snapshot.get_snapshot(search_type, search_id, context=snap_contexts[idx], version=0)
            if not current_snapshot:
                warnings.append("Current version for [%s|%s] context [%s] not found" %(search_type, search_id, snap_contexts[idx]))
                continue
            session_version, node_name  = session_data_dict.get(snap_code)
            if session_version and int(current_snapshot.get_version()) > int(session_version):
                current_snapshots.append(current_snapshot)
                sobjects.append(current_snapshot.get_sobject())
                node_names.append(node_name)
                session_versions.append(int(session_version))
        

        title = DivWdg('Outdated References')
        title.add_style('text-decoration','underline')
        div.add(title)

        # draw the nodes to be udpated
        for idx, current_snap in enumerate(current_snapshots):
            
            cb = CheckboxWdg(my.REF_CB_NAME)
            cb.add_class('spt_ref')
            cb.add_style('display: none')
            sobj = sobjects[idx]
            node_name = node_names[idx]
            session_version = session_versions[idx]
            snapshot = current_snap
            cb_value = my.get_input_value(sobj, snapshot)
            items = cb_value.split('|')
            items[-1] = node_name
            cb_value = '|'.join(items)
            cb.set_option('value', cb_value)
            div.add(cb)
            
            div.add('%0.1d. %s v%0.3d -> v%0.3d\n' \
                %(idx+1, node_name, session_version, snapshot.get_version()))
            div.add(HtmlElement.br())

        for warning in warnings:
            div.add(SpanWdg(warning, css='warning'))
        div.add(HtmlElement.br())
        if current_snapshots:
            # add the button
            prefix = my.PREFIX 
            update_button = ProdIconButtonWdg("Update all references")
            update_button.add_behavior({'type': "click_up",\
            'cbjs_action': '''var cousins = bvr.src_el.getParent('.spt_outdated_ref').getElements('.spt_ref');
                             cousins.each( function(x) {x.checked=true;}); py_replace_reference('%s','%s')'''
                    % (prefix, my.REF_CB_NAME)})
            div.add( SpanWdg(update_button, css='small'))
        
        return div
Example #5
0
    def get_bottom_wdg(my):
        if my.get_option('mode') == 'input':
            return
        web = WebContainer.get_web()
        if web.get_selected_app() not in ['XSI', 'Maya']:
            return
        div = DivWdg(css='spt_outdated_ref')

        refs = my.session.get_data().get_nodes("session/node/ref")
        snap_codes = []
        snap_contexts = []
        sobjects = []
        session_data_dict = {}
        asset_codes = []
        current_snapshots = []
        node_names = []
        session_versions = []
        for ref in refs:
            snap_code = Xml.get_attribute(ref, "asset_snapshot_code")
            node_name = Xml.get_attribute(ref, "name")
            version = Xml.get_attribute(ref, "asset_snapshot_version")
            asset_code = Xml.get_attribute(ref, "asset_code")
            if snap_code in snap_codes:
                continue
            snap_codes.append(snap_code)
            snap_contexts.append(
                Xml.get_attribute(ref, "asset_snapshot_context"))
            asset_codes.append(asset_code)
            session_data_dict[snap_code] = version, node_name

        # must search one by one
        warnings = []
        for idx, snap_code in enumerate(snap_codes):
            snapshot = Snapshot.get_by_code(snap_code)
            if not snapshot:
                continue
            search_type = snapshot.get_value('search_type')
            search_id = snapshot.get_value('search_id')
            sk = SearchKey.build_search_key(search_type,
                                            search_id,
                                            column='id')
            current_snapshot = Snapshot.get_snapshot(
                search_type, search_id, context=snap_contexts[idx], version=0)
            if not current_snapshot:
                warnings.append(
                    "Current version for [%s] context [%s] not found" %
                    (sk, snap_contexts[idx]))
                continue
            session_version, node_name = session_data_dict.get(snap_code)
            if session_version and int(
                    current_snapshot.get_version()) > int(session_version):
                current_snapshots.append(current_snapshot)
                sobjects.append(current_snapshot.get_sobject())
                node_names.append(node_name)
                session_versions.append(int(session_version))

        title = DivWdg('Outdated References')
        title.add_style('text-decoration', 'underline')
        div.add(title)

        # draw the nodes to be udpated
        for idx, current_snap in enumerate(current_snapshots):

            cb = CheckboxWdg(my.REF_CB_NAME)
            cb.add_class('spt_ref')
            cb.add_style('display: none')
            sobj = sobjects[idx]
            node_name = node_names[idx]
            session_version = session_versions[idx]
            snapshot = current_snap
            cb_value = my.get_input_value(sobj, snapshot)
            items = cb_value.split('|')
            items[-1] = node_name
            cb_value = '|'.join(items)
            cb.set_option('value', cb_value)
            div.add(cb)
            div.add('%0.1d. %s v%0.3d -> v%0.3d\n' \
                %(idx+1, node_name, session_version, snapshot.get_version()))
            div.add(HtmlElement.br())

        for warning in warnings:
            div.add(SpanWdg(warning, css='warning'))
        div.add(HtmlElement.br())

        if current_snapshots:
            # add the button
            prefix = my.search_type
            #input_name = '%s_%s' %(my.search_type, my.CB_NAME)
            update_button = ProdIconButtonWdg("Update all references")
            update_button.add_behavior({'type': "click_up",\
            'cbjs_action': '''var cousins = bvr.src_el.getParent('.spt_outdated_ref').getElements('.spt_ref');
                             cousins.each( function(x) {x.checked=true;}); py_replace_reference(bvr, '%s','%s')'''
                    % (prefix, my.REF_CB_NAME)})
            div.add(SpanWdg(update_button, css='small'))

        div.add(HtmlElement.br(2))
        return div