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


Python Site.get_site方法代码示例

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


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

示例1: execute

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import get_site [as 别名]
    def execute(my):
        if my.mode == 'basic':
            return

        # cache sthpw tables definitions
        from pyasm.security import Site
        site = Site.get_site()
        if site:
            key = "%s:sthpw_column_info" % site
        else:
            key = "sthpw_column_info"

        data = CacheContainer.get(key)
        if data == None:
            tables = ['project', 'search_object', 'login', 'login_group', 'login_in_group','snapshot','file','trigger','notification','ticket']
            kwargs = {
                "key": key,
                "database": 'sthpw',
                "tables": tables,
            }
            cache = TableInfoCache( **kwargs )



        # cache search object table
        search_type_cache = SearchTypeCache.get("sthpw/search_object")
        search_type_cache.build_cache_by_column("search_type")

        # cache login table
        search_type_cache = SearchTypeCache.get("sthpw/login")
        search_type_cache.build_cache_by_column("login")

        # cache login_group table
        search_type_cache = SearchTypeCache.get("sthpw/login_group")
        search_type_cache.build_cache_by_column("login_group")
开发者ID:0-T-0,项目名称:TACTIC,代码行数:37,代码来源:cache_startup.py

示例2: get_db_triggers

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import get_site [as 别名]
    def get_db_triggers(cls):

        site_triggers = Container.get(cls.KEY)
        if site_triggers == None:
            # find all of the triggers
            search = Search("sthpw/trigger")
            search.add_project_filter()
            site_triggers = search.get_sobjects()
            Container.put(cls.KEY, site_triggers)

        # find all of the project triggers
        from pyasm.biz import Project
        site = Site.get_site()
        project_code = Project.get_project_code()
        key = "%s:%s:%s" % (cls.KEY, project_code, site)
        project_triggers = Container.get(key)
        if project_triggers == None:
            if project_code not in ['admin','sthpw']:
                try:
                    search = Search("config/trigger")
                    project_triggers = search.get_sobjects()
                except SearchException as e:
                    print("WARNING: ", e)
                    project_triggers = []
            else:
                project_triggers = []
            Container.put(key, project_triggers)

        triggers = []
        triggers.extend(site_triggers)
        triggers.extend(project_triggers)
        return triggers
开发者ID:mincau,项目名称:TACTIC,代码行数:34,代码来源:trigger.py

示例3: set_project

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import get_site [as 别名]
    def set_project(cls, project_code):
        '''This is kept here because everybody is used to using this'''

        security = Environment.get_security()
        # FIXME:
        # Because it is possible to call this before one is 
        # logged in.  This is required to see the login screen.
        from pyasm.security import get_security_version
        security_version = get_security_version()
        if security_version != 1 and not project_code == 'admin':
            key = { 'code': project_code }
            key2 = { 'code': "*" }
            keys = [key, key2]
            if not security.check_access("project", keys, access="allow", default="deny"):
                user = Environment.get_login()
                if user:
                    user = user.get_value("login")
                    raise SecurityException("User [%s] is not permitted to view project [%s]" % (user, project_code))
                else:
                    raise SecurityException("User is not permitted to view project [%s]" % (project_code))

        from pyasm.security import Site
        site = Site.get_site()
        PROJECT_KEY = "Project:global:%s:" % site
        Container.put(PROJECT_KEY, project_code)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:27,代码来源:project.py

示例4: get_db_resource_by_search_type

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import get_site [as 别名]
    def get_db_resource_by_search_type(cls, search_type):
        if search_type.startswith('sthpw/'):
            # get the local db_resource
            from pyasm.security import Site
            site = Site.get_site()
            db_resource = None
            if site:
                db_resource = Site.get_db_resource(site, "sthpw")
            if not db_resource:
                db_resource = DbResource.get_default("sthpw")
            return db_resource


        project_code = cls.get_database_by_search_type(search_type)
        project = Project.get_by_code(project_code)
        if not project:
            raise Exception("Error: Project [%s] does not exist" % project_code)


        if search_type.startswith("salesforce/"):
            db_resource_code = "Salesforce"
            db_resource = DbResource.get_by_code(db_resource_code, project_code)
            return db_resource


        db_resource = project.get_project_db_resource()

        return db_resource
开发者ID:mincau,项目名称:TACTIC,代码行数:30,代码来源:project.py

示例5: clear_db_cache

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import get_site [as 别名]
    def clear_db_cache(cls):
        Container.put(cls.KEY, None)

        site = Site.get_site()

        from pyasm.biz import Project
        project_code = Project.get_project_code()
        key = "%s:%s:%s" % (cls.KEY, project_code, site)
        Container.put(key, None)
开发者ID:mincau,项目名称:TACTIC,代码行数:11,代码来源:trigger.py

示例6: get_global_project_code

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import get_site [as 别名]
 def get_global_project_code(cls):
     from pyasm.security import Site
     site = Site.get_site()
     PROJECT_KEY = "Project:global:%s:" % site
     project_code = Container.get(PROJECT_KEY)
     if not project_code:
         project_code = "admin"
         Project.set_global_project_code(project_code)
     return project_code
开发者ID:0-T-0,项目名称:TACTIC,代码行数:11,代码来源:project.py

示例7: get_display

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

        top = DivWdg()

        hash = my.kwargs.get("hash")
        Container.put("url_hash", hash)

        security = Environment.get_security()
        is_admin = security.check_access("builtin", "view_site_admin", "allow")
        if hash == "/admin" and not is_admin:
            hash = "/index"

        if not hash:
            # NOTE: this really doesn't get call anymore because an empty
            # hash gets remapped to "/index"
            widget = my.get_default_wdg()
            top.add(widget)

        # This would provide a way to get the default index widget.
        #elif hash == "/projects":
        #    widget = my.get_default_wdg()
        #    from tactic_sites.default.modules import IndexWdg
        #    top.add( IndexWdg() )
        else:
            from tactic.ui.panel import HashPanelWdg

            project_code = Project.get_project_code()
            if project_code == 'admin' and hash == '/index':
                widget = my.get_default_wdg()

            else:
                print "HASH: ", hash
                print "project: ", project_code
                from pyasm.security import Site
                print "site: ", Site.get_site()
                widget = HashPanelWdg.get_widget_from_hash(hash, return_none=True)

            if not widget:
                if hash == "/index":
                    widget = my.get_default_wdg()
                elif hash == '/admin':
                    widget = my.get_default_wdg()
                else:
                    widget = HashPanelWdg.get_widget_from_hash("/index", return_none=True)


            top.add(widget)


        return top
开发者ID:asmboom,项目名称:TACTIC,代码行数:52,代码来源:top_container_wdg.py

示例8: __init__

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import get_site [as 别名]
    def __init__(my, **kwargs):
        my.kwargs = kwargs
        user = my.kwargs.get('user')
        project = my.kwargs.get('project')

        my.site = my.kwargs.get('site')
        if not my.site:
            # if not explicitly set, keep the site that is current
            my.site = Site.get_site()

        if user and project:
            from pyasm.security import Batch
            Batch(site=my.site, login_code=user, project_code=project)

        my.security = Environment.get_security()
开发者ID:asmboom,项目名称:TACTIC,代码行数:17,代码来源:scheduler.py

示例9: get_by_key

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import get_site [as 别名]
    def get_by_key(cls, key, search_type=None):
        from pyasm.security import Site
        site = Site.get_site()
        Site.set_site( Site.get_first_site() )

        project = Project.get_project_code() 
        dict_key = '%s:%s' %(key, search_type)
       
        search = Search(cls.SEARCH_TYPE, project_code=project)
        search.add_filter("key", key)
        if search_type:
            search.add_filter("search_type", search_type)

        if Project.get_project_name() in ['admin', 'sthpw']:
            return None
        prod_setting = ProdSetting.get_by_search(search, dict_key)

        Site.pop_site()

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

示例10: get_project_db_resource

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import get_site [as 别名]
    def get_project_db_resource(my, database=None):
        # get the db resource for attached to this particular project.
        # Not the db_resource for "sthpw/project" for which
        # project.get_db_resource() does
        from pyasm.security import Site
        site = Site.get_site()
        if site:
            key = "Project:db_resource_cache:%s" % site
        else:
            key = "Project:db_resource_cache"

        resource_dict = Container.get(key)
        if resource_dict:
            resource = resource_dict.get( my.get_code() )
            if resource != None:
                return resource
        else:
            resource_dict = {}
            Container.put(key, resource_dict)


        # the project defines the resource
        if not database:
            database = my.get_database_name()
        assert database

        if database == 'sthpw':
            # get if from the config
            db_resource_code = None
        else:
            db_resource_code = my.get_value("db_resource", no_exception=True)

        if not db_resource_code:
            # this could be any project, not just sthpw
            # already looked at cache, so set use_cache to False
            db_resource = Site.get_db_resource(site, database)
            if not db_resource:
                db_resource = DbResource.get_default(database, use_cache=False)
            #db_resource = DbResource.get_default(database, use_cache=False)
            resource_dict[key] = db_resource
            return db_resource
        #elif isinstance(db_resource_code, DbResource):
        elif DbResource.is_instance(db_resource_code):   
            db_resource = db_resource_code
            resource_dict[key] = db_resource
            return db_resource


        db_resource_code = db_resource_code.strip()
        search = Search("sthpw/db_resource")
        search.add_filter("code", db_resource_code)
        db_resource_sobj = search.get_sobject()
        if not db_resource_sobj:
            raise TacticException("Database Resource [%s] does not exist" % db_resource_code)


        host = db_resource_sobj.get_value("host")
        vendor = db_resource_sobj.get_value("vendor")
        host = db_resource_sobj.get_value("host")
        port = db_resource_sobj.get_value("port")
        user = db_resource_sobj.get_value("login")
        password = db_resource_sobj.get_value("password")
       
        db_resource = DbResource(user=user, database=database, host=host, port=port, vendor=vendor, password=password)
        #Container.put(key, db_resource)
        resource_dict[key] = db_resource

        return db_resource
开发者ID:jayvdb,项目名称:TACTIC,代码行数:70,代码来源:project.py

示例11: get_display

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import get_site [as 别名]

#.........这里部分代码省略.........
                spt.confirm("Are you sure you wish to sign out?", ok )
                '''
            } )



            div.add("<b>ADMIN >></b>")


            div.add_behavior( {
                'type': 'listen',
                'event_name': 'close_admin_bar',
                'cbjs_action': '''
                bvr.src_el.getParent(".spt_top").setStyle("padding-top", "0px");
                spt.behavior.destroy_element(bvr.src_el);
                '''
            } )

            div.add_behavior( {
                'type': 'mouseover',
                'cbjs_action': '''
                bvr.src_el.setStyle("opacity", 0.85)
                //new Fx.Tween(bvr.src_el).start('height', "30px");
                '''
            } )
            div.add_behavior( {
                'type': 'mouseout',
                'cbjs_action': '''
                bvr.src_el.setStyle("opacity", 0.7)
                //new Fx.Tween(bvr.src_el).start('height', "15px");
                '''
            } )
            project_code = Project.get_project_code()
            site_root = web.get_site_root()
            div.add_behavior( {
                'type': 'click_up',
                'site_root': site_root,
                'project_code': project_code,
                'cbjs_action': '''
                var url = "/"+bvr.site_root+"/"+bvr.project_code+"/admin/link/_startup";
                window.open(url);
                '''
            } )





        # Add the script editor listener
        load_div = DivWdg()
        top.add(load_div)
        load_div.add_behavior( {
        'type': 'listen',
        'event_name': 'show_script_editor',
        'cbjs_action': '''
        var js_popup_id = "TACTIC Script Editor";
        var js_popup = $(js_popup_id);
        if( js_popup ) {
            spt.popup.toggle_display( js_popup_id, false );
        }
        else {
            spt.panel.load_popup(js_popup_id, "tactic.ui.app.ShelfEditWdg", {}, {"load_once": true} );
        }
        '''} )

开发者ID:asmboom,项目名称:TACTIC,代码行数:68,代码来源:top_wdg.py

示例12: execute

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import get_site [as 别名]
    def execute(self):
      
        input_data = self.get_input_data()
        data = self.data


        # add site info to the data object
        site = Site.get_site()
        if site and not data.get("site"):
            data['site'] = site

        result = True


        # input data for the handler
        if self.mode == 'separate process,blocking':
            input_data_str = jsondumps(input_data)
            data_str = jsondumps(data)

            file = __file__
            py_exec = Config.get_value("services", "python")
            if not py_exec:
                py_exec = "python"


            retcode = subprocess.call([py_exec, file, data_str, input_data_str])



        elif self.mode == 'separate process,non-blocking':
            input_data_str = jsondumps(input_data)
            data_str = jsondumps(data)

            file = __file__
            py_exec = Config.get_value("services", "python")
            if not py_exec:
                py_exec = "python"

            retcode = subprocess.Popen([py_exec, file, data_str, input_data_str])

            result = "wait"

        elif self.mode == 'separate process,queued':

            kwargs = data.get("kwargs")
            priority = kwargs.get("priority") or 99999
            description = kwargs.get("description") or "Trigger"
            queue_type = kwargs.get("trigger") or "trigger"

            class_name = "pyasm.command.QueueTrigger"
            kwargs = {
                'input_data': input_data,
                'data': data,
            }

            from tactic.command import Queue
            queue_item = Queue.add(class_name, kwargs, queue_type=queue_type, priority=priority, description=description)

            result = "wait"


        elif self.mode == 'same process,new transaction':
            # run it inline
            trigger = ScriptTrigger()
            trigger.set_data(data)
            trigger.set_input(input_data)
            trigger.execute()


        # if it was not overridden by the trigger, the return default for the mode
        if not self.info.has_key("result"):
            self.info['result'] = result
开发者ID:mincau,项目名称:TACTIC,代码行数:74,代码来源:subprocess_trigger.py

示例13: create_sobject_log

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import get_site [as 别名]
    def create_sobject_log(cls, log, transaction_data=None):

        if not transaction_data:
            transaction_data = log.get_value("transaction")

        # log a reference to each sobject affected
        already_logged = {}
        xml = Xml()
        xml.read_string(transaction_data)
        nodes = xml.get_nodes("transaction/*")


        # list of sobjects not logged
        not_logged = set([
            'sthpw/transaction_log',
            'sthpw/clipboard',
            'sthpw/sobject_log',
            'sthpw/file',
            'sthpw/message',
            'sthpw/message_log',
        ])

        find_parent = set([
            'sthpw/snapshot',
            'sthpw/note',
            'sthpw/task'
        ])


        from pyasm.security import Site
        current_site = Site.get_site()


        for node in nodes:
            node_name = xml.get_node_name(node)
            if node_name == "sobject":
                search_type = Xml.get_attribute(node,"search_type")
                search_type_obj = SearchType.get(search_type)


                if search_type_obj.get_base_key() in not_logged:
                    continue


                search_id = Xml.get_attribute(node,"search_id")
                search_code = Xml.get_attribute(node,"search_code")
                site = Xml.get_attribute(node,"site")


                if search_code:
                    search_key = "%s?code=%s" % (search_type, search_code)
                else:
                    search_key = "%s|%s" % (search_type, search_id)


                if already_logged.get(search_key):
                    continue
                already_logged[search_key] = True

                # delete items are not presently logged ...
                # TODO: maybe they should be
                action = Xml.get_attribute(node,"action")
                if action == "delete":
                    continue


                has_site = False
                if site:
                    try:
                        Site.set_site(site)
                        has_site = True
                    except:
                        print "Site [%s] does not exist" % site
                        continue


                try:

                    if search_code:
                        sobject = Search.get_by_code(search_type, search_code)
                    else:
                        sobject = Search.get_by_id(search_type, search_id)


                    if sobject:
                        SObjectLog.create(sobject, log, action)
                    else:
                        # record has been deleted
                        if search_code:
                            print("Skipped SObject log creation for [%s?code=%s]" %(search_type, search_code))
                        else:
                            print("Skipped SObject log creation for [%s|%s]" %(search_type, search_id))

                    if search_type_obj.get_base_key() in find_parent:
                        try:
                            if sobject:
                                sobject = sobject.get_parent()
                        except (SearchException, SqlException):
                            # don't worry if this parent can't be found.
                            pass
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:transaction_log.py

示例14: add_top_behaviors

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import get_site [as 别名]

#.........这里部分代码省略.........
            }


            spt.tab.set_main_body_tab()

            if (view) {
                var cls = "tactic.ui.panel.CustomLayoutWdg";
                var kwargs = {
                    view: view
                }
            }
            else if (search_key) {
                var cls = "tactic.ui.tools.SObjectDetailWdg";
                var kwargs = {
                    search_key: search_key
                }
            }


            var attributes = bvr.src_el.attributes;
            for (var i = 0; i < attributes.length; i++) {
                var attr_name = attributes[i].name;
                if (attr_name == "class") {
                    continue;
                }
                var value = attributes[i].value;
                kwargs[attr_name] = value;
            }


            try {
                spt.tab.add_new(name, title, cls, kwargs);
            } catch(e) {
                spt.alert(e);
            }
            '''
            } )



        self.body.add_relay_behavior( {
            'type': 'click',
            'bvr_match_class': 'tactic_submit',
            'cbjs_action': '''
            var command = bvr.src_el.getAttribute("command");
            var kwargs = {
            }
            var server = TacticServerStub.get();
            try {
                server.execute_cmd(command, kwargs);
            } catch(e) {
                spt.alert(e);
            }
            '''
            } )


        self.body.add_relay_behavior( {
            'type': 'mouseenter',
            'bvr_match_class': 'tactic_hover',
            'cbjs_action': '''
            var bgcolor = bvr.src_el.getStyle("background");
            bvr.src_el.setAttribute("spt_bgcolor", bgcolor);
            bvr.src_el.setStyle("background", "#EEE");
            '''
            } )

        self.body.add_relay_behavior( {
            'type': 'mouseleave',
            'bvr_match_class': 'tactic_hover',
            'cbjs_action': '''
            var bgcolor = bvr.src_el.getAttribute("spt_bgcolor");
            if (!bgcolor) bgcolor = "";
            //var bgcolor = ""
            bvr.src_el.setStyle("background", bgcolor);
            '''
            } )

        self.body.set_unique_id()
        self.body.add_smart_style( "tactic_load", "cursor", "pointer" )


        # check version of the database
        project = Project.get()
        version = project.get_value("last_version_update")
        release = Environment.get_release_version()
        #if version < release:
        # FIXME: can't do this ... TACTIC cannot be running when the database
        # is upgrading.
        if False:
            try:
                from pyasm.security import Site
                site = Site.get_site()
                install_dir = Environment.get_install_dir()
                cmd = '''python "%s/src/bin/upgrade_db.py" -f -s "%s" --quiet --yes &''' % (install_dir, site)
                print("cmd: ", cmd)
                os.system(cmd)
                pass
            except Exception as e:
                print("WARNING: ", e)
开发者ID:mincau,项目名称:TACTIC,代码行数:104,代码来源:top_wdg.py


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