Пример #1
0
 def get_instantiation_options(my):
     options = ['reference', 'import', 'open']
     if WebContainer.get_web().get_selected_app() == 'Houdini':
         options = ['import', 'open']
     elif WebContainer.get_web().get_selected_app() == 'XSI':
         options = ['open']
     return options
Пример #2
0
    def init(self):
        #print "DEPRECATED"
        #raise TacticException("Use of GeneralAppletWdg is Deprecated")

        # it's generated thru JS in IE
        if WebContainer.get_web().is_IE():
            return

        context_url = WebContainer.get_web().get_context_url()

        print "-" * 20
        print self.APPLET_CLASS

        # create applet
        applet = HtmlElement("applet")
        applet.set_attr("code", self.APPLET_CLASS)
        applet.set_attr("codebase", "%s/java" % context_url.get_url())
        applet.set_attr("archive", self.APPLET_JAR)
        applet.set_attr("width", "1")
        applet.set_attr("height", "1")
        applet.set_attr("id", self.APPLET_ID)

        # create param for applet
        param = HtmlElement("param")
        param.set_attr("name", "scriptable")
        param.set_attr("value", "true")

        applet.add(param)

        self.add(applet)
Пример #3
0
    def init(self):
        #print "DEPRECATED"
        #raise TacticException("Use of GeneralAppletWdg is Deprecated")

        # it's generated thru JS in IE
        if WebContainer.get_web().is_IE():
            return
        
        context_url = WebContainer.get_web().get_context_url()
        
        print "-"*20
        print self.APPLET_CLASS


        # create applet
        applet = HtmlElement("applet")
        applet.set_attr("code", self.APPLET_CLASS)
        applet.set_attr("codebase", "%s/java" % context_url.get_url() )
        applet.set_attr("archive", self.APPLET_JAR)
        applet.set_attr("width", "1")
        applet.set_attr("height", "1")
        applet.set_attr("id", self.APPLET_ID)
    
        # create param for applet
        param = HtmlElement("param")
        param.set_attr("name","scriptable")
        param.set_attr("value","true")

        applet.add(param)
        
        self.add(applet)
Пример #4
0
 def get_instantiation_options(my):
     options = ["reference", "import", "open"]
     if WebContainer.get_web().get_selected_app() == "Houdini":
         options = ["import", "open"]
     elif WebContainer.get_web().get_selected_app() == "XSI":
         options = ["open"]
     return options
Пример #5
0
 def get_instantiation_options(self):
     options = ['reference', 'import', 'open']
     if WebContainer.get_web().get_selected_app() == 'Houdini':
         options = ['import', 'open']
     elif WebContainer.get_web().get_selected_app() == 'XSI':
         options = ['open']
     return options
Пример #6
0
 def check(my):
     my.add = WebContainer.get_web().get_form_value(\
         SObjectGroupWdg.ADD_LABEL) != ''
     my.remove = WebContainer.get_web().get_form_value(\
         SObjectGroupCmd.REMOVE_CMD) != ''
     if my.add or my.remove:
         if my.grouping_search_type and my.item_foreign_key and \
                 my.container_foreign_key:
             return True
     else:
         return False
Пример #7
0
 def check(my):
     my.add = WebContainer.get_web().get_form_value(\
         SObjectGroupWdg.ADD_LABEL) != ''
     my.remove = WebContainer.get_web().get_form_value(\
         SObjectGroupCmd.REMOVE_CMD) != ''
     if my.add or my.remove:
         if my.grouping_search_type and my.item_foreign_key and \
                 my.container_foreign_key:
             return True
     else:
         return False
Пример #8
0
 def check(self):
     self.add = WebContainer.get_web().get_form_value(\
         SObjectGroupWdg.ADD_LABEL) != ''
     self.remove = WebContainer.get_web().get_form_value(\
         SObjectGroupCmd.REMOVE_CMD) != ''
     if self.add or self.remove:
         if self.grouping_search_type and self.item_foreign_key and \
                 self.container_foreign_key:
             return True
     else:
         return False
Пример #9
0
    def get_display(self):
        # set up the self refresh event for other widgets or callbacks to call
        event_container = WebContainer.get_event_container()
        script = ClipboardWdg.get_self_refresh_script(show_progress=False)
        event_container.add_listener(self.EVENT_ID, script, replace=True )

        if self.is_from_ajax():
            div = Widget()
        else:
            div = DivWdg()
            div.set_id(self.ID)
            div.add_style("display: block")
            div.add_class("background_box")
            div.add_style("padding-left: 3px")
            div.add_style("padding-right: 3px")
            div.add_style("height: 1.5em")
            div.add_style("width: 150px")

        # handle the ajax
        self.set_ajax_top_id(self.ID)
        self.register_cmd(ClipboardClearCbk)
        refresh_script = self.get_refresh_script()

        search = Search("sthpw/clipboard")
        search.add_user_filter()
        search.add_filter("category", "select")
        count = search.get_count()

        div.add("Clipboard: %s items: " % count)


        web = WebContainer.get_web()
        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.widget.ClipboardListWdg")
        ref = url.to_string()

        iframe = WebContainer.get_iframe()
        iframe.set_width(64)
        action = iframe.get_on_script(ref)
       
        button = IconButtonWdg("View Clipboard", IconWdg.LOAD)
        button.add_event("onclick", action)
        div.add(button)



        # add the clear clipboard icon
        clear_icon = IconButtonWdg("Clear Clipboard", IconWdg.CLEAR)
        clear_icon.add_event("onclick", refresh_script)

        div.add(clear_icon)

        return div
Пример #10
0
    def get_display(self):
        # set up the self refresh event for other widgets or callbacks to call
        event_container = WebContainer.get_event_container()
        script = ClipboardWdg.get_self_refresh_script(show_progress=False)
        event_container.add_listener(self.EVENT_ID, script, replace=True)

        if self.is_from_ajax():
            div = Widget()
        else:
            div = DivWdg()
            div.set_id(self.ID)
            div.add_style("display: block")
            div.add_class("background_box")
            div.add_style("padding-left: 3px")
            div.add_style("padding-right: 3px")
            div.add_style("height: 1.5em")
            div.add_style("width: 150px")

        # handle the ajax
        self.set_ajax_top_id(self.ID)
        self.register_cmd(ClipboardClearCbk)
        refresh_script = self.get_refresh_script()

        search = Search("sthpw/clipboard")
        search.add_user_filter()
        search.add_filter("category", "select")
        count = search.get_count()

        div.add("Clipboard: %s items: " % count)

        web = WebContainer.get_web()
        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.widget.ClipboardListWdg")
        ref = url.to_string()

        iframe = WebContainer.get_iframe()
        iframe.set_width(64)
        action = iframe.get_on_script(ref)

        button = IconButtonWdg("View Clipboard", IconWdg.LOAD)
        button.add_event("onclick", action)
        div.add(button)

        # add the clear clipboard icon
        clear_icon = IconButtonWdg("Clear Clipboard", IconWdg.CLEAR)
        clear_icon.add_event("onclick", refresh_script)

        div.add(clear_icon)

        return div
Пример #11
0
    def _checkin(my, instance, context, asset_type='asset', is_current=True, \
            is_revision=True, snapshot_type="asset", texture_search_type=None):
        '''retrieve the asset sobject and run the checkin command'''
        
        web = WebContainer.get_web()
        namespace, asset_code, instance_name = instance.split("|")
        description = WebContainer.get_web().get_form_value(\
            "%s_description" % instance_name)

        # get the sobject from asset_code
        
        my.sobject = Search.get_by_code(my.search_type, asset_code)
        if my.sobject == None:
            raise CommandException("SObject '%s' does not exist'" % asset_code)
        # now checkin the asset
        checkin = None

        # we assume asset_type = 'asset' by default
        if asset_type == 'asset':
            checkin = MayaAssetCheckin(my.sobject)
            checkin.set_instance(instance_name)
            checkin.set_option('texture_search_type', texture_search_type)
        elif asset_type =='set':
            checkin = MayaGroupCheckin(my.sobject)
        else:
            raise CommandException('Unknown asset type[%s] found' %asset_type)
        checkin.set_description(description)
        checkin.set_process(my.process)
        checkin.set_context(context)
        checkin.set_current(is_current)
        checkin.set_revision(is_revision)
        use_handoff_dir = web.get_form_value("use_handoff_dir")
        if use_handoff_dir in ['true','on']:
            checkin.set_use_handoff(True)
        if snapshot_type:
            checkin.set_snapshot_type(snapshot_type)

        checkin.set_option("unknown_ref", web.get_form_value("unknown_ref"))
        checkin.execute()

        snapshot = checkin.get_snapshot()
        version = snapshot.get_version()
        if description == "":
            description = "<No description>"
        my.add_description("Checked in %s '%s', context: %s, v%0.3d, %s" % \
            (asset_type.capitalize(), instance_name, context, version, description))
       
        my.sobjects = [my.sobject]
Пример #12
0
    def _checkin(my, instance, context, asset_type='asset', is_current=True, \
            is_revision=True, snapshot_type="asset", texture_search_type=None):
        '''retrieve the asset sobject and run the checkin command'''

        web = WebContainer.get_web()
        namespace, asset_code, instance_name = instance.split("|")
        description = WebContainer.get_web().get_form_value(\
            "%s_description" % instance_name)

        # get the sobject from asset_code

        my.sobject = Search.get_by_code(my.search_type, asset_code)
        if my.sobject == None:
            raise CommandException("SObject '%s' does not exist'" % asset_code)
        # now checkin the asset
        checkin = None

        # we assume asset_type = 'asset' by default
        if asset_type == 'asset':
            checkin = MayaAssetCheckin(my.sobject)
            checkin.set_instance(instance_name)
            checkin.set_option('texture_search_type', texture_search_type)
        elif asset_type == 'set':
            checkin = MayaGroupCheckin(my.sobject)
        else:
            raise CommandException('Unknown asset type[%s] found' % asset_type)
        checkin.set_description(description)
        checkin.set_process(my.process)
        checkin.set_context(context)
        checkin.set_current(is_current)
        checkin.set_revision(is_revision)
        use_handoff_dir = web.get_form_value("use_handoff_dir")
        if use_handoff_dir in ['true', 'on']:
            checkin.set_use_handoff(True)
        if snapshot_type:
            checkin.set_snapshot_type(snapshot_type)

        checkin.set_option("unknown_ref", web.get_form_value("unknown_ref"))
        checkin.execute()

        snapshot = checkin.get_snapshot()
        version = snapshot.get_version()
        if description == "":
            description = "<No description>"
        my.add_description("Checked in %s '%s', context: %s, v%0.3d, %s" % \
            (asset_type.capitalize(), instance_name, context, version, description))

        my.sobjects = [my.sobject]
Пример #13
0
 def handle_config(my):
     '''for search type display config'''
     web = WebContainer.get_web()
     WidgetDbConfig.append(my.search_type,
                           my.view,
                           my.element_name,
                           config_xml=my.config_xml)
Пример #14
0
    def get_value(self, name):
        web = WebContainer.get_web()
        value = web.get_form_value(name)
        if not value:
            value = self.kwargs.get(name)

        return value
Пример #15
0
    def get_input_value(my, name):
        value = my.kwargs.get(name)
        if value == None:
            web = WebContainer.get_web()
            value = web.get_form_value(name)

        return value
Пример #16
0
    def get_display(my):

        web = WebContainer.get_web()
        user = WebContainer.get_user_name()
        local_dir = web.get_local_dir()
        context_url = web.get_site_context_url().to_string()
        server = web.get_base_url().to_string()
        upload_url = web.get_upload_url()

        html = Html()

        html.writeln('''\n<script>try{ app = new PyXSI(); }
                                catch(e){
                                    app = null;}
        if (app) {
            app.user = '******';
            app.local_dir = '%(local_dir)s';
            app.context_url = '%(context_url)s';
            app.base_url = '%(server)s';
            app.upload_url = '%(upload_url)s';
            app.project_code = '%(project_code)s';} </script>'''%{'user': user,
                                           'local_dir': local_dir,
                                           'context_url' : context_url,
                                           'server': server,
                                           'upload_url':  upload_url,
                                           'project_code':  Project.get_project_code()})
                            


        return html
Пример #17
0
    def execute(self):
        self.search_key_list = self.kwargs.get('search_key_list')
        web = WebContainer.get_web()
        skip_duplicated = web.get_form_value('skip_duplicated') == 'on'
        pipeline_mode = web.get_form_value('pipeline_mode')

        sobjects = SearchKey.get_by_search_keys(self.search_key_list)
        count = 0
        offset = 0
        for sobject in sobjects:
            if isinstance(sobject, Task):
                raise TacticException('Creation of task for [Task] is not allowed')
            sk = SearchKey.get_by_sobject(sobject)
            if not sobject.has_value('pipeline_code'):
                #raise TacticException('Creation of task is not allowed for item with no pipeline_code attribute.')
                pipeline_code = '__default__'
                sobject.set_value("pipeline_code", pipeline_code)
            else:
                pipeline_code = sobject.get_value('pipeline_code')
            input_name = '%s|task_process'% pipeline_code
            
            contexts = []
            process_names = web.get_form_values(input_name)
            process_names = [name for name in process_names if name]
            if pipeline_mode == 'context':
                # when pipeline_mode is context, we only specify contexts
                # in add_initial_tasks
                contexts = process_names[:]
                process_names = []
            tasks = Task.add_initial_tasks(sobject, sobject.get_value('pipeline_code'),
                    processes=process_names, contexts=contexts, skip_duplicate=skip_duplicated, mode=pipeline_mode, start_offset=offset)

            count += len(tasks)
            offset += 5
        self.add_description("%s Tasks added in total." % count)
Пример #18
0
    def init(my):
        """initialize the widget_config, and from there retrieve the schema_config"""
        web = WebContainer.get_web()
        my.search_type = my.kwargs.get("search_type")

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

        # FIXME: comment out the assert for now to avoid error screen
        if not my.view:
            my.view = "table"
        # assert my.view

        my.config_xml = my.kwargs.get("config_xml")
        if not my.config_xml:
            my.config_xml = web.get_form_value("config_xml")

        my.default = my.kwargs.get("default") == "True"

        cbk = ManageSearchTypeDetailCbk(search_type=my.search_type, view=my.view, element_name=element_name)
        Command.execute_cmd(cbk)

        my.config_string = ""
        my.data_type_string = ""
        my.name_string = ""
        my.title_string = ""
        my.nullable_string = ""
        my.has_column = True

        if element_name:
            if my.config_xml:
                my.config_string = my.config_xml
                whole_config_string = "<config><%s>%s</%s></config>" % (my.view, my.config_xml, my.view)
                config = WidgetConfig.get(xml=whole_config_string, view=my.view)
                my.config = WidgetConfigView(my.search_type, my.view, [config])
            else:
                # don't pass in default here
                my.config = my.get_config(my.search_type, my.view)
                node = my.config.get_element_node(element_name)
                if node is not None:
                    config_xml = my.config.get_xml()

                    my.config_string = config_xml.to_string(node)
                    my.title_string = config_xml.get_attribute(node, "title")
            schema_config = SearchType.get_schema_config(my.search_type)

            attributes = schema_config.get_element_attributes(element_name)
            my.data_type_string = attributes.get("data_type")

            # double_precision is float
            if my.data_type_string == "double precision":
                my.data_type_string = "float"

            my.name_string = attributes.get("name")
            my.nullable_string = attributes.get("nullable")
            my.is_new_column = attributes.get("new") == "True"

            # a database columnless widget
            if not my.name_string:
                my.has_column = False
Пример #19
0
    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()
Пример #20
0
    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
Пример #21
0
    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()
Пример #22
0
    def check(my):
        web = WebContainer.get_web()
        if web.get_form_value(MayaAssetCheckinWdg.PUBLISH_BUTTON) == "":
            return False
        my.search_type = my.kwargs.get('search_type')
        if not my.search_type:
            my.search_type = 'prod/asset'
        my.texture_search_type = my.kwargs.get('texture_search_type')
        if not my.texture_search_type:
            my.texture_search_type = 'prod/texture'

        # get the process to check this asset in (NEW)
        my.process = web.get_form_value("%s_process" % my.search_type)
        # get the context to check this asset in
        my.context = web.get_form_value("%s_context" % my.search_type)
        if not my.context:
            raise UserException('Please select a context in the drop-down.')
            return False

        sub_context = web.get_form_value("%s_sub_context" % my.search_type)

        if sub_context:
            my.context = "%s/%s" % (my.context, sub_context)

        return True
Пример #23
0
    def execute(my):

        #my.snapshot_dict = {}

        web = WebContainer.get_web()

        current_section_name = web.get_form_value(MayaSetWdg.CURRENT_SECTION)
        if not current_section_name:
            raise CommandExitException()

        description = web.get_form_value("description")

        current_section_instance, current_section_code = current_section_name.split(
            "|")

        # get the sobject from asset_code
        current_section = Asset.get_by_code(current_section_code)
        if current_section == None:
            # try the name instead
            current_section = Asset.get_by_name(current_section_instance)
            if current_section == None:
                raise CheckinException("Cannot find asset '%s'" %
                                       current_section_code)

        # now checkin the asset
        checkin = MayaGroupCheckin(current_section)
        checkin.set_description(description)
        checkin.set_context(my.context)
        checkin.execute()

        my.add_description("Set '%s': %s" %
                           (current_section_code, description))
        #my.snapshot_dict[current_section_name] = checkin.snapshot

        web.set_form_value('publish_search_type', 'prod/asset')
Пример #24
0
    def execute(my):

        # make sure tmp config is unset.
        Config.unset_tmp_config()
        Config.reload_config()

        web = WebContainer.get_web()

        vendor = web.get_form_value("database/vendor")

        if vendor == 'Sqlite':
            db_dir = web.get_form_value("database/sqlite_db_dir")
            database = "sthpw"
            db_path = "%s/%s.db" % (db_dir, database)
            if os.path.exists(db_path):
                return

        elif vendor == 'PostgreSQL':
            my.test_postgres(vendor)
            return

        elif vendor in ['MySQL', 'SQLServer', 'Oracle']:
            my.test_postgres(vendor)
            return

        my.info['error'] = "Cannot connect to database"
Пример #25
0
    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()
Пример #26
0
    def get_display(my):

        sobject = my.get_current_sobject()

        widget_class = my.get_option("class")
        
        if widget_class == '':
            raise WidgetException("No widget class defined")

        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", widget_class)
        url.set_option("search_key", sobject.get_search_key())

        ref = url.get_url()

        iframe = Container.get("iframe")
        iframe.set_width(90)
        action = iframe.get_on_script(ref)

        info_type = my.get_option("info_type")
        
        button = IconButtonWdg("%s info" % info_type, IconWdg.INFO)
        button.add_event("onclick", "%s" % (action) )
        button.add_style("margin: 3px 5px")

        return button
Пример #27
0
    def get_display(self):
        web = WebContainer.get_web()

        widget = Widget()

        search_type = web.get_form_value("parent_search_type")
        search_id = web.get_form_value("parent_search_id")

        if not search_type:
            widget.add("RenderSubmitInfo: parent type not found")
            return widget

        hidden = HiddenWdg("parent_search_type", search_type)
        widget.add(hidden)
        hidden = HiddenWdg("parent_search_id", search_id)
        widget.add(hidden)

        sobject = Search.get_by_id(search_type, search_id)
        table = TableWdg(search_type, css="embed")
        table.set_show_property(False)
        table.set_sobject(sobject)
        table.remove_widget("render")
        table.remove_widget("description")
        widget.add(table)

        return widget
Пример #28
0
    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()
Пример #29
0
 def check(self):
     web = WebContainer.get_web()
     if web.get_form_value("Render") == "" and web.get_form_value(
             "do_edit").startswith("Submit/") == "":
         return False
     else:
         return True
Пример #30
0
    def get_value(my, name):
        value = my.kwargs.get(name)
        if value == None:
            web = WebContainer.get_web()
            value = web.get_form_value(name)

        return value
Пример #31
0
    def get_display(my):
        widget = Widget()

        thumb = super(ThumbPublishWdg, my).get_display()

        widget.add(thumb)
        sobject = my.get_current_sobject()
        search_type = sobject.get_search_type()
        search_id = sobject.get_id()

        publish_link = PublishLinkWdg(search_type, search_id)
        div = DivWdg(publish_link)
        div.set_style('clear: left; padding-top: 6px')
        widget.add(div)

        # build an iframe to show publish browsing
        browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS)
        iframe = WebContainer.get_iframe()
        iframe.set_width(100)

        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.prod.web.PublishBrowserWdg")
        url.set_option("search_type", search_type)
        url.set_option("search_id", search_id)
        script = iframe.get_on_script(url.to_string())
        browse_link.add_event("onclick", script)

        div.add(browse_link)
        div.set_style('padding-top: 6px')

        return widget
Пример #32
0
    def check(my):
        search_key = my.kwargs.get('search_key')
        my.sobject = SearchKey.get_by_search_key(search_key)
        
        from pyasm.web import WebContainer
        web = WebContainer.get_web()

        my.old_password = web.get_form_value("old password")
        if isinstance(my.old_password, list):
            my.old_password = my.old_password[0]
        #encrypted = md5.new(my.old_password).hexdigest()
        encrypted = hashlib.md5(my.old_password).hexdigest()
        
        if encrypted != my.sobject.get_value('password'):
            raise UserException('Old password is incorrect.')
        my.password = web.get_form_value("password")
        if isinstance(my.password, list):
            my.password = my.password[0]


        if my.sobject == None:
            return UserException("Current user cannot be determined.")

        my.re_enter = web.get_form_value("password re-enter")
        if isinstance(my.re_enter, list):
            my.re_enter = my.re_enter[0]
        if my.re_enter != "" and my.re_enter != my.password:
            raise UserException( "Passwords must match. Please fill in the re-enter.")

        return True
Пример #33
0
    def execute(self):
        sobject = self.sobject

        name = self.get_name()

        web = WebContainer.get_web()

        naming = web.get_form_value(name)

        if not naming:
            return

        naming_util = NamingUtil()
        template = naming_util.build_naming2(naming)

        naming = naming.strip("/")
        parts = re.split('[\\/._]', naming)

        # make some adjustments based on selections
        for idx, part in enumerate(parts):

            type_value = web.get_form_value("type_%s" % idx)

            if type_value:
                template = template.replace("{%d}" % idx, "{%s}" % type_value)
            else:
                template = template.replace("{%d}" % idx, part)

        sobject.set_value(name, template)
Пример #34
0
    def get_file_type_wdg(my):
        '''drop down which selects which file type to export to'''
        # add a filter
        div = DivWdg()

        filter_div = FloatDivWdg(HtmlElement.b("File Type:"), width="15em")
        div.add(filter_div)

        select = SelectWdg()
        select.set_name("file_type")
        select.set_id("file_type")

        app = WebContainer.get_web().get_selected_app()

        if app == 'Maya':
            select.set_option("values", "mayaAscii|mayaBinary|obj|collada")
            select.set_option("labels", "Maya Ascii (.ma)|Maya Binary (.mb)|Wavefront .obj|Collada (.dae)")
        elif app == 'Houdini':
            select.set_option("values", "otl")
            select.set_option("labels", "Houdini Digital Asset(.otl)")
        elif app == 'XSI':
            select.set_option("values", "emdl|dotXSI|obj")
            select.set_option("labels", "3D Model (.emdl)|SoftImage dotXSI (.xsi)|Wavefront .obj")
        else:
            select.set_option("values", "mayaAscii|mayaBinary|obj|collada")
            select.set_option("labels", "Maya Ascii (.ma)|Maya Binary (.mb)|Wavefront .obj|Collada (.dae)")

        select.add_style("font-size: 0.8em")
        select.add_style("margin-top: 5px")
        select.add_style("margin-right: 10px")
        select.set_persistence()
        
        div.add(select)
        return div
Пример #35
0
    def init(my):
        web = WebContainer.get_web()
        
        my.is_refresh = my.kwargs.get('is_refresh')
        my.search_type = my.kwargs.get('search_type')
        if not my.search_type:
            my.search_type = web.get_form_value('search_type_filter')
        my.close_cbfn = my.kwargs.get('close_cbfn')

        my.web_url = web.get_form_value("web_url")
        my.file_path = None
        if my.web_url:
            import urllib2
            response = urllib2.urlopen(my.web_url)
            csv = response.read()
            my.file_path = "/tmp/test.csv"
            f = open(my.file_path, 'w')
            f.write(csv)
            f.close()

        if not my.file_path:
            my.file_path =  web.get_form_value('file_path')


        if not my.file_path:
            file_name =  web.get_form_value('file_name')
            ticket =  web.get_form_value('html5_ticket')
            if not ticket:
                ticket =  web.get_form_value('csv_import|ticket')
                
            if file_name:
                # this is treated the same in FileUplaod class
                file_name = File.get_filesystem_name(str(file_name))
                my.file_path = '%s/%s' %(web.get_upload_dir(ticket=ticket), file_name)
Пример #36
0
    def url_commit(my):

        from pyasm.web import WebContainer
        web = WebContainer.get_web()
        group_name = web.get_form_value("group_name")
        group = LoginGroup.get_by_group_name(group_name)

        attr = SecurityRulesAttr(group, "access_rules")

        # go through each msg and process
        change_made = False
        msgs = web.get_form_values("url_levels")
        for msg in msgs:
            url, level = msg.split("|")

            try:
                attr.add_url_access(url, level)
            except CommandExitException:
                pass
            else:
                change_made = True

        # only commit if a change has bee made
        if change_made:
            group.set_value("access_rules", attr.get_xml())
            group.commit()
        else:
            raise CommandExitException()

        my.description = "Modified url '%s' security settings" % url
Пример #37
0
    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()
Пример #38
0
    def execute(my):
        sobject = my.sobject

        name = my.get_name()

        web = WebContainer.get_web()

        naming = web.get_form_value(name)

        if not naming:
            return

        naming_util = NamingUtil()
        template = naming_util.build_naming2(naming)

        naming = naming.strip("/")
        parts = re.split("[\\/._]", naming)

        # make some adjustments based on selections
        for idx, part in enumerate(parts):

            type_value = web.get_form_value("type_%s" % idx)

            if type_value:
                template = template.replace("{%d}" % idx, "{%s}" % type_value)
            else:
                template = template.replace("{%d}" % idx, part)

        sobject.set_value(name, template)
Пример #39
0
    def get_display(my):
        widget = Widget()
        
        thumb = super(ThumbPublishWdg, my).get_display()

        widget.add(thumb)
        sobject = my.get_current_sobject()
        search_type = sobject.get_search_type()
        search_id = sobject.get_id()

        publish_link = PublishLinkWdg(search_type,search_id) 
        div = DivWdg(publish_link)
        div.set_style('clear: left; padding-top: 6px')
        widget.add(div)

        # build an iframe to show publish browsing
        browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS)
        iframe = WebContainer.get_iframe()
        iframe.set_width(100)

        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.prod.web.PublishBrowserWdg")
        url.set_option("search_type", search_type)
        url.set_option("search_id", search_id)
        script = iframe.get_on_script(url.to_string())
        browse_link.add_event("onclick", script)

        div.add(browse_link)
        div.set_style('padding-top: 6px')


        return widget
Пример #40
0
    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"

        for security_group in security_groups:
            if not security_group:
                continue

            search = Search("sthpw/login_group")
            search.add_filter("login_group", security_group)
            login_group = search.get_sobject()
            assert login_group

            access_rules = login_group.get_xml_value("access_rules")

            # add the rule to each group
            builder = AccessRuleBuilder(access_rules)
            builder.add_rule(rule_group, my.element_name, "deny")

            login_group.set_value("access_rules", builder.to_string())
            login_group.commit()
Пример #41
0
    def configure_asset_dir(my):

        web = WebContainer.get_web()
        keys = web.get_form_keys()
        option_list = []
        for key in keys:
            if key.startswith('checkin/'):
                key = key.replace('checkin/','')
                option_list.append(key)
  
        asset_dir = web.get_form_value("checkin/asset_base_dir")
        if asset_dir != None:
            if asset_dir and not os.path.exists(asset_dir):
                os.makedirs(asset_dir)
            Config.set_value("checkin", "asset_base_dir", asset_dir)

        if 'asset_base_dir' in option_list:
            option_list.remove('asset_base_dir')

        for item_dir in option_list:
            item_in_list=web.get_form_value('checkin/%s'%item_dir)
            if item_in_list:
                Config.set_value("checkin", '%s'%item_dir, item_in_list)
            else:
                Config.set_value("checkin", '%s'%item_dir, "")
Пример #42
0
    def configure_asset_dir(my):
        my.section = 'Asset Management Setup'

        web = WebContainer.get_web()
        keys = web.get_form_keys()
        option_list = []
        for key in keys:
            if key.startswith('checkin/'):
                key = key.replace('checkin/', '')
                option_list.append(key)

        asset_dir = web.get_form_value("checkin/asset_base_dir")
        if asset_dir != None:
            if asset_dir and not os.path.exists(asset_dir):
                os.makedirs(asset_dir)
            Config.set_value("checkin", "asset_base_dir", asset_dir)

        if 'asset_base_dir' in option_list:
            option_list.remove('asset_base_dir')

        for item_dir in option_list:
            item_in_list = web.get_form_value('checkin/%s' % item_dir)
            if item_in_list:
                Config.set_value("checkin", '%s' % item_dir, item_in_list)
            else:
                Config.set_value("checkin", '%s' % item_dir, "")
Пример #43
0
    def init(self):

        help = HelpItemWdg(
            'Loader',
            'The Loader lets you load 3D assets into your 3D applications. Among many options, you can choose to either reference, import, or open the asset through http or the internal file system.'
        )
        self.add(help)

        pref = PrefSetting.get_value_by_key("use_java_maya")
        app = WebContainer.get_web().get_app_name_by_uri()

        if app == "Maya":
            if not Container.get('GeneralAppletWdg'):
                self.add(GeneralAppletWdg())
                Container.put('GeneralAppletWdg', True)
        site_menu = SiteMenuWdg()
        site_menu.add_style("float", "right")
        site_menu.add_style("margin-top", "-2px")
        self.add(site_menu)

        WebContainer.add_js('MayaWebTools.js')
        WebContainer.add_js('PyMaya.js')

        tab = MayaTabWdgImpl()
        tab_value = tab.set_tab_key("maya_tab")
        #self.handle_tab(tab)
        #self.add(tab,"tab")
        self.setup_tab("maya_tab", tab=tab)
        self.add(ProgressWdg())
Пример #44
0
    def url_commit(self):

        from pyasm.web import WebContainer
        web = WebContainer.get_web()
        group_name = web.get_form_value("group_name")
        group = LoginGroup.get_by_group_name(group_name)

        attr = SecurityRulesAttr(group,"access_rules")

        # go through each msg and process
        change_made = False
        msgs = web.get_form_values("url_levels")
        for msg in msgs:
            url, level = msg.split("|")

            try:
                attr.add_url_access(url,level)
            except CommandExitException:
                pass
            else:
                change_made = True

        # only commit if a change has bee made
        if change_made:
            group.set_value("access_rules", attr.get_xml() )
            group.commit()
        else:
            raise CommandExitException()


        self.description = "Modified url '%s' security settings" % url
Пример #45
0
    def get_value(self, name):
        web = WebContainer.get_web()
        value = web.get_form_value(name)
        if not value:
            value = self.kwargs.get(name)

        return value
Пример #46
0
    def get_display(my):
        if my.is_refresh:
            top = Widget()
            my.add(top)
            web = WebContainer.get_web()
            my.checked_processes = web.get_form_values('process_names')
            left_checked_processes = web.get_form_values('left_process_names')
            right_checked_processes = web.get_form_values(
                'right_process_names')
            is_split_view = web.get_form_value('split_view') == 'true'
        else:
            top = my.get_viewer()

        if my.is_refresh:
            if is_split_view:
                viewer = my.get_split_viewer()
                top.add(viewer)
            else:
                inner_wdg = SingleNoteViewerWdg(
                    processes_names=my.process_names,
                    parent_key=my.kwargs.get('parent_key'),
                    resize='false',
                    append_context=my.append_context,
                    view=my.view)
                top.add(inner_wdg)

        return top
Пример #47
0
    def execute(my):
        plugin = my.sobject

        web = WebContainer.get_web()
        value = web.get_form_value( my.get_input_name() )
        if not value:
            return
        src_search_keys = jsonloads(value)


        manifest = plugin.get_xml_value("manifest")

        top_node = manifest.get_node("manifest")

        for search_key in src_search_keys:
            sobject = SearchKey.get_by_search_key(search_key)

            node = manifest.create_element("sobject")

            # For now, a plugin must contain project specfic entries
            search_type = sobject.get_base_search_type()
            code = sobject.get_value("code")
            manifest.set_attribute(node, "search_type", search_type)
            manifest.set_attribute(node, "code", code)

            #search_key = SearchKey.get_by_sobject(sobject)
            #manifest.set_attribute(node, "search_key", search_key)

            manifest.append_child(top_node, node)

        plugin.set_value("manifest", manifest.to_string() )
        plugin.commit()
Пример #48
0
    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
Пример #49
0
 def init(my):
     my.search_type = my.kwargs.get("search_type")
     if not my.search_type:
         my.search_type = WebContainer.get_web().get_form_value("search_type")
     my.view = my.kwargs.get("view")
     if not my.view:
         my.view = "database_definition"
Пример #50
0
    def _add_icon(my):
        # icon is optional
        if not my.icon_path:
            return
        
        if not my.icon_path.startswith("/"):
            # icon_path = "/context/icons/oo/%s" % my.icon_path
            icon_path = "/context/icons/silk/%s" % my.icon_path
        else:
            icon_path = my.icon_path

        icon = HtmlElement.img(icon_path)
        icon.set_attr("title", my.name)
        icon.add_styles(my.icon_styles)   
        if my.long:
            img_id = my.generate_unique_id(my.name)
            icon.add_class("icon_out") 
            my.add_event("onmouseover","wdg_opacity('%s','over');" % (img_id))
            my.add_event("onmouseout","wdg_opacity('%s','out');" % (img_id))
            icon.set_id(img_id)
        else:
            icon.add_class("simple_button")


        if WebContainer.get_web().is_IE():
            icon.add_style("vertical-align: top")
        else:
            icon.add_style("vertical-align: middle")
       
        my.add(icon)
Пример #51
0
    def postprocess(my):
        web = WebContainer.get_web()
        value = web.get_form_value(my.get_input_name())
        if not value:
            return

        # get all fo the sobjects from the search keys
        instance_type = my.get_option("instance_type")

        # path is used for self-relating in an instance table
        src_path = my.get_option("path")

        #src_sobject = my.sobject

        search = Search(my.sobject.get_search_type())
        search.add_id_filter(my.sobject.get_id())
        src_sobject = search.get_sobject()

        # this is passed in from EditCmd in insert mode
        parent_key = my.get_option('parent_key')
        # in some rare cases we have project as the parent_key
        if parent_key and my.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()
Пример #52
0
    def execute(my):

        # make sure tmp config is unset.
        Config.unset_tmp_config()
        Config.reload_config()

        web = WebContainer.get_web()

        vendor = web.get_form_value("database/vendor")


        if vendor == 'Sqlite':
            db_dir = web.get_form_value("database/sqlite_db_dir")
            database = "sthpw"
            db_path = "%s/%s.db" % (db_dir, database)
            if os.path.exists(db_path):
                return

        elif vendor == 'PostgreSQL':
            my.test_postgres(vendor)
            return

        elif vendor in ['MySQL','SQLServer','Oracle']:
            my.test_postgres(vendor)
            return

        my.info['error'] = "Cannot connect to database"
Пример #53
0
    def check(my):
        search_key = my.kwargs.get('search_key')
        my.sobject = SearchKey.get_by_search_key(search_key)

        from pyasm.web import WebContainer
        web = WebContainer.get_web()

        my.old_password = web.get_form_value("old password")
        if isinstance(my.old_password, list):
            my.old_password = my.old_password[0]
        #encrypted = md5.new(my.old_password).hexdigest()
        encrypted = hashlib.md5(my.old_password).hexdigest()

        if encrypted != my.sobject.get_value('password'):
            raise UserException('Old password is incorrect.')
        my.password = web.get_form_value("password")
        if isinstance(my.password, list):
            my.password = my.password[0]

        if my.sobject == None:
            return UserException("Current user cannot be determined.")

        my.re_enter = web.get_form_value("password re-enter")
        if isinstance(my.re_enter, list):
            my.re_enter = my.re_enter[0]
        if my.re_enter != "" and my.re_enter != my.password:
            raise UserException(
                "Passwords must match. Please fill in the re-enter.")

        return True
Пример #54
0
    def execute(my):
        plugin = my.sobject

        web = WebContainer.get_web()
        value = web.get_form_value( my.get_input_name() )
        if not value:
            return
        src_search_keys = jsonloads(value)


        manifest = plugin.get_xml_value("manifest")

        top_node = manifest.get_node("manifest")

        for search_key in src_search_keys:
            sobject = SearchKey.get_by_search_key(search_key)

            node = manifest.create_element("sobject")

            # For now, a plugin must contain project specfic entries
            search_type = sobject.get_base_search_type()
            code = sobject.get_value("code")
            manifest.set_attribute(node, "search_type", search_type)
            manifest.set_attribute(node, "code", code)

            #search_key = SearchKey.get_by_sobject(sobject)
            #manifest.set_attribute(node, "search_key", search_key)

            manifest.append_child(top_node, node)

        plugin.set_value("manifest", manifest.to_string() )
        plugin.commit()
Пример #55
0
    def get_css_wdg(my):

        widget = Widget()

        web = WebContainer.get_web()
        context_url = web.get_context_url().to_string()

        skin = web.get_skin()

        # first load context css
        Container.append_seq("Page:css", "%s/style/layout.css" % context_url)


        # add the color wheel css
        Container.append_seq("Page:css", "%s/spt_js/mooRainbow/Assets/mooRainbow.css" % context_url)
        Container.append_seq("Page:css", "%s/spt_js/mooDialog/css/MooDialog.css" % context_url)



        # get all of the registered css file
        css_files = Container.get_seq("Page:css")
        for css_file in css_files:
            widget.add('<link rel="stylesheet" href="%s" type="text/css" />\n' % css_file )

       
        # TEST TEST TEST
        widget.add('<link rel="stylesheet" href="/assets/_video/video-js.min.css" type="text/css" />\n')
        return widget
Пример #56
0
    def postprocess(self):
        web = WebContainer.get_web()
        values = web.get_form_values("select_key")
        if not values or values == ['']:
            return

        dst_sobject = self.sobject

        project_code = Project.get_project_code()

        for value in values:
            src_sobject = Search.get_by_search_key(value)
            if not src_sobject:
                continue
            connection = SearchType.create("sthpw/connection")
            connection.set_value("src_search_type",
                                 src_sobject.get_search_type())
            connection.set_value("dst_search_type",
                                 dst_sobject.get_search_type())
            connection.set_value("src_search_id", src_sobject.get_id())
            connection.set_value("dst_search_id", dst_sobject.get_id())
            connection.set_value("context", "reference")
            connection.set_value("project_code", project_code)

            connection.commit()
Пример #57
0
    def execute(self):

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

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

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

        rule_group = "side_bar"

        for security_group in security_groups:
            if not security_group:
                continue

            search = Search("sthpw/login_group")
            search.add_filter("login_group", security_group)
            login_group = search.get_sobject()
            assert login_group

            access_rules = login_group.get_xml_value("access_rules")

            # add the rule to each group
            builder = AccessRuleBuilder(access_rules)
            builder.add_rule(rule_group, self.element_name, "deny")

            login_group.set_value("access_rules", builder.to_string())
            login_group.commit()
Пример #58
0
    def get_top_wdg(my):

        #if not my.hash and not my.custom_url:
        #    search = Search("config/url")
        #    search.add_filter("url", "/index")
        #    my.custom_url = search.get_sobject()

        # NOTE: this is not the right place for this, but it allows the
        # top widget to completely be customized

        # if there is a custom url, then handle it separately
        if my.custom_url:
            xml = my.custom_url.get_xml_value("widget")
            index = xml.get_value("element/@index")
            admin = xml.get_value("element/@admin")
            bootstrap = xml.get_value("element/@bootstrap")
            if index == 'true' or admin == 'true':
                pass
            elif bootstrap == 'true':
                widget = BootstrapIndexWdg()
                return widget
            else:
                web = WebContainer.get_web()
                hash = "/".join(my.hash)
                hash = "/%s" % hash
                my.top = CustomTopWdg(url=my.custom_url, hash=hash)
                return my.top

        # This is the default TACTIC html implementation for html
        my.top = TopWdg(hash=my.hash)
        return my.top
Пример #59
0
 def init(self):
     self.search_type = self.kwargs.get('search_type')
     if not self.search_type:
         self.search_type = WebContainer.get_web().get_form_value('search_type')
     self.view = self.kwargs.get('view')
     if not self.view:
         self.view = "database_definition"